/* FamilyHub — mobil öncelikli stil sayfası (Türkçe arayüz)
   Temel stiller 320–430px dikey telefon; min-width:700px ile iki bölmeli masaüstü. */

:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #23252b;
  --muted: #6b7280;
  --line: #e6e2da;
  --accent: #5b74c9;
  --accent-ink: #ffffff;
  --danger: #b3413f;
  --ok: #3d8b62;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181d;
    --card: #21232b;
    --ink: #e8e6e1;
    --muted: #a09d97;
    --line: #33363f;
    --accent: #8fa5e8;
    --accent-ink: #10121a;
    --danger: #e07a76;
    --ok: #6cc197;
  }
}

/* ---- Büyük yazı / yüksek kontrast anahtarları ---- */
[hidden] { display: none !important; }
html.large-text {
  font-size: 20.8px;
}
html.high-contrast {
  --bg: #fffdf8;
  --card: #ffffff;
  --ink: #000000;
  --muted: #333333;
  --line: #4a4a4a;
  --accent: #0f3ea8;
  --accent-ink: #ffffff;
  --danger: #8e1b1b;
  --ok: #14532d;
}
html.high-contrast .r-sub,
html.high-contrast .bubble-time,
html.high-contrast .hint,
html.high-contrast time,
html.high-contrast .chip {
  color: var(--ink);
}
@media (prefers-color-scheme: dark) {
  html.high-contrast {
    --bg: #000000;
    --card: #101010;
    --ink: #ffffff;
    --muted: #e6e6e6;
    --line: #bdbdbd;
    --accent: #ffd166;
    --accent-ink: #000000;
    --danger: #ff8a80;
    --ok: #9ae6b4;
  }
  html.high-contrast .r-sub,
  html.high-contrast .bubble-time,
  html.high-contrast .hint,
  html.high-contrast time,
  html.high-contrast .chip {
    color: var(--ink);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.45;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- Giriş ekranı ---------------- */
.login-wrap {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  display: grid;
  gap: 16px;
}
.f-label { display: grid; gap: 6px; font-size: 0.92rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  min-height: 48px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
textarea { resize: vertical; }

.login-error {
  margin: 0;
  color: var(--danger);
  font-weight: 600;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  padding: 13px 18px;
  min-height: 48px;
  cursor: pointer;
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.btn.wide { width: 100%; }
.btn.subtle { opacity: 0.85; }

/* ---------------- Üst bar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who strong { font-size: 1rem; }
.who time { display: block; font-size: 0.78rem; color: var(--muted); }
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex: none;
}
.avatar.sm { width: 32px; height: 32px; font-size: 0.85rem; }
.topnav { margin-left: auto; display: inline-flex; gap: 4px; align-items: center; }
.bar-title { font-size: 1.05rem; margin: 0 auto; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--ink);
  background: transparent;
  border: none;
  cursor: pointer;
  flex: none;
}
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); text-decoration: none; }
.icon-btn.danger:hover { background: color-mix(in srgb, var(--danger) 15%, transparent); }

/* ---------------- Bölümler / kartlar / satırlar ---------------- */
.section { padding: 14px 14px 4px; max-width: 720px; margin: 0 auto; }
.sec-title { font-size: 0.86rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 10px 2px 8px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  color: inherit;
}
.row:hover { text-decoration: none; border-color: var(--accent); }
.grow { min-width: 0; flex: 1; display: block; }
.r-title { display: block; font-weight: 600; }
.r-sub { display: block; font-size: 0.82rem; color: var(--muted); margin-top: 2px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; }
.chip {
  font-size: 0.75rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  border-radius: 999px;
  padding: 4px 10px;
  flex: none;
  white-space: nowrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  vertical-align: middle;
}
.empty { color: var(--muted); font-size: 0.92rem; padding: 6px 2px; }
.big-empty { padding: 40px 16px; text-align: center; }
.more-link { display: inline-block; margin: 4px 2px 10px; font-size: 0.9rem; }
.flash {
  background: color-mix(in srgb, var(--ok) 14%, var(--card));
  border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line));
  color: var(--ok);
  font-weight: 600;
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 10px;
}
.hint { color: var(--muted); font-size: 0.84rem; }

/* ---------------- Takvim ---------------- */
.cal-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.cal-head, .cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.nav-btn {
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  border-radius: 12px;
  color: var(--ink);
}
.nav-btn:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); text-decoration: none; }
table.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { font-size: 0.72rem; color: var(--muted); font-weight: 600; padding: 6px 0; }
.cal th.wknd { color: var(--danger); }
.cal td { text-align: center; padding: 0; }
.cal td.day { height: 46px; }
.cal td.day a {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
}
.cal td.day a:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); text-decoration: none; }
.cal td.today a { box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }
.cal td.sel a { background: var(--accent); color: var(--accent-ink); }
.dots { position: absolute; bottom: 3px; display: inline-flex; gap: 2px; }
.evdot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--dc, var(--accent));
  display: inline-block;
}
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.today-lg { box-shadow: inset 0 0 0 2px var(--accent); }
.ev-lg { background: var(--muted); }
.cal-legend { font-size: 0.78rem; color: var(--muted); margin: 8px 0 2px; }
.sub-details { margin-bottom: 10px; }
.sub-details summary { cursor: pointer; color: var(--accent); padding: 6px 2px; }

/* ---------------- Yapılacaklar ---------------- */
.todo-card { margin-bottom: 10px; }
.todo-card.overdue { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.todo-main { display: flex; align-items: flex-start; gap: 10px; }
.check-btn {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 12px;
  border: 2px solid var(--muted);
  background: transparent;
  color: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.check-btn.done {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.t-title {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  word-break: break-word;
}
.todo-card.done-item .t-title { text-decoration: line-through; }
.flag { color: var(--danger); align-self: center; }
.todo-meta { margin-top: 8px; font-size: 0.82rem; color: var(--muted); }
.todo-meta .sep { opacity: 0.5; }
.todo-notes { margin: 6px 0 0; font-size: 0.88rem; color: var(--muted); word-break: break-word; }
.inline-form { display: inline-flex; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.frow.btns { grid-template-columns: 1fr 1fr; }
.compact-form { padding: 10px; margin-top: 6px; }

/* ---------------- Ekleme alanları ---------------- */
.add-bar-wrap { padding-bottom: 16px; }
.add-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
  padding: 10px 2px;
}
.add-form { display: grid; gap: 10px; margin-top: 8px; }

/* ---------------- Modül düğmeleri ---------------- */
.module-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-bottom: 16px;
}
.module-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 96px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
}
.module-btn:hover { border-color: var(--accent); text-decoration: none; }
.module-btn .mi { font-size: 1.5rem; }
.module-btn .badge { position: absolute; top: 8px; right: 10px; }
.module-btn.subtle { background: transparent; border-style: dashed; color: var(--muted); }

/* ---------------- Alt gezinme ---------------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 7px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}
.bn-item .bni-icon { font-size: 1.25rem; line-height: 1; }
.bn-item.on { color: var(--accent); }
.bn-item:hover { text-decoration: none; color: var(--ink); }

/* ---------------- Mesajlar ---------------- */
.thread { display: flex; flex-direction: column; gap: 8px; padding-bottom: 90px; }
.bubble {
  max-width: 82%;
  border-radius: 18px;
  padding: 9px 13px 6px;
  background: var(--card);
  border: 1px solid var(--line);
}
.bubble.mine {
  align-self: flex-end;
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.bubble.theirs { align-self: flex-start; }
.bubble-body { word-break: break-word; white-space: pre-wrap; }
.bubble-time { display: block; font-size: 0.7rem; opacity: 0.65; margin-top: 3px; text-align: right; }
.composer-wrap {
  position: fixed;
  left: 0; right: 0;
  bottom: 56px;
  z-index: 35;
  padding: 8px 12px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 30%);
}
.composer { display: flex; gap: 8px; max-width: 720px; margin: 0 auto; }
.composer textarea { flex: 1; min-height: 48px; max-height: 120px; }
.send-btn { width: 52px; flex: none; border-radius: 12px; }

/* ---------------- Sohbet (Ollama) ---------------- */
.chat-thread { padding-bottom: 160px; }
.chat-status {
  max-width: 720px;
  margin: 0 auto;
  font-size: 0.75rem;
  color: var(--muted);
  min-height: 1.15em;
}
.chat-status.error { color: var(--danger); }
.chat-status.ok { color: var(--ok); }
.model-select { flex: none; width: auto; max-width: 42%; font-size: 0.8rem; color: var(--muted); border-radius: 12px; }
.bubble-body p { margin: 0 0 6px; }
.bubble-body p:last-child { margin-bottom: 0; }
.bubble-body pre {
  background: color-mix(in srgb, var(--ink) 7%, var(--card));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  overflow-x: auto;
  white-space: pre-wrap;
}
.bubble-body code { background: color-mix(in srgb, var(--ink) 7%, var(--card)); border-radius: 5px; padding: 1px 5px; font-size: 0.85em; }
.bubble-body pre code { background: transparent; padding: 0; }
.bubble-body ul, .bubble-body ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble-body h1, .bubble-body h2, .bubble-body h3 { font-size: 1em; margin: 8px 0 4px; }
/* Biçimli içerik sarmalayıcısı: akış sırasındaki pre-wrap'i sıfırlar */
.bubble-body .md { white-space: normal; }
.bubble-body .md h3, .bubble-body .md h4, .bubble-body .md h5, .bubble-body .md h6 { font-size: 1em; margin: 8px 0 4px; font-weight: 700; }
.bubble-body .md blockquote {
  border-left: 3px solid color-mix(in srgb, var(--ink) 20%, transparent);
  margin: 6px 0;
  padding: 2px 10px;
  opacity: 0.85;
}
.new-chat-card { margin-bottom: 10px; }
.new-chat-card > summary { list-style: none; cursor: pointer; }
.new-chat-card > summary::-webkit-details-marker { display: none; }

.chev { color: var(--muted); font-size: 1.2rem; }
.settings-form { display: grid; gap: 12px; }
.hint-card { margin-top: 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 600; }
.switch-row input[type="checkbox"] { width: 26px; min-height: 26px; accent-color: var(--accent); }
.color-pick { border: none; padding: 0; margin: 0; }
.color-pick legend { font-size: 0.85rem; color: var(--muted); padding: 0; margin-bottom: 6px; }
.swatch input { position: absolute; opacity: 0; width: 0; min-height: 0; }
.swatch span { display: inline-flex; width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 2px solid transparent; }
.swatch input:checked + span { border-color: var(--ink); box-shadow: 0 0 0 2px var(--card) inset; }
.user-card { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }

/* ---------------- Segment görünüm seçici (Açık / Tamamlanan) ---------------- */
.seg {
  display: flex;
  gap: 4px;
  margin: 12px 14px 4px;
  padding: 4px;
  background: color-mix(in srgb, var(--ink) 6%, var(--bg));
  border-radius: 12px;
}
.seg-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 9px;
  font-weight: 600;
  color: var(--muted);
}
.seg-btn:hover { text-decoration: none; color: var(--ink); }
.seg-btn.on {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}
.seg-n {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  font-size: 0.78rem;
  text-align: center;
}
.seg-btn.on .seg-n { background: var(--accent); color: var(--accent-ink); }

/* ---------------- Yapılacaklar: ortak parçalar ---------------- */
.todo-list { display: flex; flex-direction: column; }
.edit-form {
  margin: 6px 0 12px;
  grid-column: 1 / -1;
  padding: 12px;
  border-left: 2px solid var(--accent);
  display: grid;
  gap: 10px;
}

/* ---------------- Yapılacaklar: Palm-Pilot satırı ---------------- */
.todo-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 6px 2px;
}
.todo-row:last-child { border-bottom: none; }
.td-check { display: inline-flex; }
.check-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--ink) 35%, transparent);
  background: transparent;
  color: transparent;
  cursor: pointer;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  padding: 0;
}
.check-btn:hover { border-color: var(--ok); }
.check-btn.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.t-title {
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.t-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.done-item .t-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }

/* öncelik işareti (Palm tarzı küçük kare) */
.prio-btn {
  width: 14px; height: 14px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  flex: none;
  border-radius: 3px;
}
.prio-btn.p2 { box-shadow: inset 0 0 0 14px var(--danger); }   /* yüksek = dolu kırmızı */
.prio-btn.p1 { box-shadow: inset 0 0 0 1.5px var(--muted); }   /* normal = boş kare   */
.prio-btn.p0 { box-shadow: inset 0 0 0 1.5px var(--line); }    /* düşük = soluk kare  */

/* tarih rozeti */
.due-badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  min-width: 52px;
  text-align: right;
  list-style: none;
  cursor: pointer;
}
.due-badge.today { color: var(--accent); }
.due-badge.far { color: var(--muted); opacity: 0.75; }
.todo-row.overdue .due-badge { color: var(--danger); }
.due-badge.none { opacity: 0.55; }
.due-badge::-webkit-details-marker { display: none; }

/* açılır menüler (öncelik + tarih) — JS'siz <details> tabanlı */
.pop-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 4px);
  left: 0;
  min-width: 150px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
  padding: 4px;
  display: grid;
  gap: 2px;
}
.pop-menu button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.9rem;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
}
.pop-menu button:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.pop-menu button.cur { color: var(--accent); font-weight: 700; }
.prio-pop, .date-pop { position: relative; display: inline-flex; }
.prio-pop > summary, .date-pop > summary { list-style: none; cursor: pointer; }
.prio-pop[open] .pop-menu, .date-pop[open] .pop-menu { display: grid; }
.date-pop .pop-menu { left: auto; right: 0; }
.pop-menu .pick { display: flex; gap: 4px; padding: 4px; }
.pop-menu .pick input[type="date"] {
  flex: 1;
  min-height: 38px;
  padding: 4px 8px;
  font-size: 0.85rem;
}
.pop-menu .pick button {
  width: auto;
  padding: 4px 10px;
}

/* ---------------- Ekleme butonu + sayfa altı form ---------------- */
.add-bar-wrap { position: relative; margin-top: auto; padding-bottom: 84px; }
.new-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}
.new-btn:hover { border-color: var(--accent); }
.new-btn::-webkit-details-marker { display: none; }
.add-form.sheet {
  position: static;
  z-index: 45;
  margin: 0;
  box-shadow: none;
}

/* ---------------- Üst bar / modül ızgarasında iç formlar ---------------- */
.inline-form { display: inline-flex; align-items: center; margin: 0; }
.module-form { display: contents; }
#title-anchor-start { scroll-margin-top: 70px; }

/* ---------------- Masaüstü iyileştirmeleri ---------------- */
@media (min-width: 700px) {
  body { padding-bottom: 24px; }
  .bottom-nav { display: none; }
  .section { padding: 18px 20px 6px; }
  .module-grid { grid-template-columns: repeat(4, 1fr); }
  .login-card { max-width: 380px; }
  .topbar-inner, .section, .composer { }
  .thread { padding-bottom: 110px; }
  .composer-wrap { bottom: 0; }
}

/* ---------------- Küçük yazıcı kuralı ---------------- */
@media print {
  .bottom-nav, .topnav, .add-bar-wrap { display: none; }
}
