/* Sofuoğlu Aile Şeceresi — kişi odaklı görünüm */
:root {
  --paper: #ffffff;
  --wash: #f3f6f4;
  --ink: #18201c;
  --ink-2: #4f5a54;
  --ink-3: #5b6660;
  --rule: #dfe5e1;
  --lineage: #1f7a4d;       /* afişteki yeşil soy çizgisi */
  --lineage-wash: #e6f2eb;
  --story: #9a5b13;          /* aile anlatıları (rivayet) */
  --female: #a3456f;         /* kız evlat */
  --danger: #b42318;
  --focus: #1f7a4d;

  --st-no_children: #d13b3b;
  --st-daughters_only: #3a86c8;
  --st-outside_village: #e08a3c;
  --st-unknown_lineage: #9aa19d;

  --rail: 52px;             /* soy çizgisinin soldan uzaklığı */
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121614;
    --wash: #1b211e;
    --ink: #e9eeeb;
    --ink-2: #b2bcb6;
    --ink-3: #9aa49e;
    --rule: #2a322e;
    --lineage: #4cc285;
    --lineage-wash: #183326;
    --story: #e0a458;
    --female: #e58fb4;
    --danger: #ff8a7a;
    --focus: #4cc285;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.45 var(--font);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- üst çubuk ---------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px;
  padding: 0 8px 0 16px;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.home { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; min-height: 48px; min-width: 44px; }
.home svg { color: var(--lineage); }
.icon-btn {
  display: grid; place-items: center;
  width: 48px; height: 48px;
  border: 0; background: none; border-radius: 50%;
  color: var(--ink); cursor: pointer;
}
.icon-btn:active { background: var(--wash); }

/* ---------- sayfa ---------- */
.view {
  width: 100%; max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px 32px;
  flex: 1;
}
.loading { color: var(--ink-3); padding: 48px 0; text-align: center; }

.intro { padding: 20px 0 4px; }
.intro h1 { font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; margin: 0 0 8px; }
.intro p { margin: 0; color: var(--ink-2); max-width: 34em; }

/* Soy çizgisi: atalar + seçili kişi aynı dikey çizginin üstünde durur */
.stem { position: relative; }
.stem::before {
  content: ""; position: absolute;
  left: calc(var(--rail) - 1.5px); top: 0; bottom: 0;
  width: 3px; background: var(--lineage); border-radius: 2px;
}
.stem.from-top::before { top: 41px; }

.anc {
  position: relative;
  display: flex; align-items: center;
  min-height: 48px;
  padding-left: calc(var(--rail) + 20px);
  color: var(--ink-2);
}
.anc .gen {
  position: absolute; left: 0; width: calc(var(--rail) - 16px);
  text-align: right; font-size: 15px; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.anc::after {          /* çizgi üstündeki nokta */
  content: ""; position: absolute;
  left: calc(var(--rail) - 5px); top: 50%; margin-top: -5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--paper); border: 2.5px solid var(--lineage);
}
.anc .n { font-weight: 600; color: var(--ink); }
.anc .y { margin-left: 8px; font-size: 15px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
a.anc:active { background: var(--wash); }
button.anc {
  width: 100%; border: 0; background: none; text-align: left; cursor: pointer;
  color: var(--lineage); font-weight: 600; font-size: 15px;
}
button.anc::after { border-style: dotted; background: var(--paper); }

/* Seçili kişi */
.me {
  position: relative;
  padding: 18px 0 22px calc(var(--rail) + 20px);
}
.me::after {
  content: ""; position: absolute;
  left: calc(var(--rail) - 11px); top: 30px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--lineage);
  box-shadow: 0 0 0 6px var(--lineage-wash);
}
.me .gen {
  position: absolute; left: 0; top: 30px; width: calc(var(--rail) - 22px);
  text-align: right; font-size: 15px; line-height: 22px; color: var(--lineage); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.me h1 {
  margin: 0;
  font-size: clamp(30px, 9vw, 40px); line-height: 1.08;
  font-weight: 800; letter-spacing: -.025em;
  overflow-wrap: anywhere;
}
.me .meta { margin: 6px 0 0; color: var(--ink-2); font-size: 16px; }
.me .meta b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.status {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 6px 12px 6px 10px;
  border-radius: 999px; background: var(--wash);
  font-size: 15px; font-weight: 500;
}
.note { margin: 12px 0 0; color: var(--ink-2); font-size: 16px; max-width: 32em; }
.review {
  margin: 12px 0 0; padding: 10px 12px;
  border-left: 3px solid var(--st-outside_village);
  background: color-mix(in srgb, var(--st-outside_village) 10%, var(--paper));
  font-size: 15px; color: var(--ink-2); border-radius: 0 8px 8px 0;
}
.me-actions { display: flex; flex-wrap: wrap; gap: 0 20px; margin-top: 10px; }
.text-btn {
  border: 0; background: none; padding: 0; min-height: 44px;
  color: var(--lineage); font-weight: 600; font-size: 15px; cursor: pointer;
}
.text-btn.quiet { color: var(--ink-3); }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.st-no_children { background: var(--st-no_children); }
.dot.st-daughters_only { background: var(--st-daughters_only); }
.dot.st-outside_village { background: var(--st-outside_village); }
.dot.st-unknown_lineage { background: var(--st-unknown_lineage); }

/* Çocuklar: çizgiden dallanan satırlar */
.branch { position: relative; padding-bottom: 8px; }
.branch h2, .sibs h2 {
  margin: 8px 0 4px calc(var(--rail) + 20px);
  font-size: 15px; font-weight: 700; color: var(--ink-3);
}
.kids { list-style: none; margin: 0; padding: 0; position: relative; }
.kids::before {   /* çocuklara inen gri çizgi */
  content: ""; position: absolute;
  left: calc(var(--rail) - 1px); top: -40px; bottom: 28px;
  width: 2px; background: var(--rule);
}
.kids li { position: relative; }
.kids li::before {  /* çizgiden satıra yatay dal */
  content: ""; position: absolute;
  left: var(--rail); top: 50%; width: 14px; height: 2px; background: var(--rule);
}
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 60px;
  margin-left: calc(var(--rail) + 14px);
  padding: 8px 8px 8px 12px;
  border-radius: 12px;
}
a.row:active, a.row:hover { background: var(--wash); }
.row .txt { flex: 1; min-width: 0; }
.row .n { font-weight: 600; font-size: 18px; }
.row .y { margin-left: 6px; color: var(--ink-3); font-size: 15px; font-variant-numeric: tabular-nums; }
.row .sub { display: block; font-size: 15px; color: var(--ink-3); }
.row .chev { color: var(--ink-3); width: 20px; height: 20px; }
.row.add {
  width: calc(100% - var(--rail) - 14px);
  border: 1.5px dashed var(--rule); background: none; cursor: pointer;
  color: var(--lineage); font-weight: 600; text-align: left;
}
.row.add:active { background: var(--lineage-wash); }
.empty { margin: 0 0 4px calc(var(--rail) + 26px); color: var(--ink-3); font-size: 15px; }

.sibs { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--rule); }
.sibs .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-left: calc(var(--rail) + 20px); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 6px 14px;
  border: 1px solid var(--rule); border-radius: 999px;
  font-size: 15px; font-weight: 500;
}
.chip .y { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chip:active { background: var(--wash); }

/* Gezinme geçişi: yeni kişi hafifçe yerine oturur */
@media (prefers-reduced-motion: no-preference) {
  .view.enter .me, .side.enter .me { animation: settle .28s cubic-bezier(.2, .7, .2, 1); }
  .view.enter .branch, .view.enter .sibs { animation: fade .35s ease-out; }
}
@keyframes settle { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade { from { opacity: 0; } }

/* ---------- alt bilgi ---------- */
.foot {
  width: 100%; max-width: 640px; margin: 0 auto;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
  color: var(--ink-3); font-size: 15px;
}
.foot p { margin: 0 0 10px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 10px; }

/* ---------- arama ---------- */
dialog { color: var(--ink); background: var(--paper); border: 0; padding: 0; }
dialog::backdrop { background: rgb(10 20 15 / .45); }
.search {
  width: 100%; max-width: 640px; height: 100dvh; max-height: none;
  margin: 0 auto; inset: 0;
}
@media (min-width: 700px) {
  .search { height: auto; max-height: 80dvh; margin-top: 8dvh; border-radius: 16px; }
}
.search-head {
  position: sticky; top: 0; background: var(--paper);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 16px; padding-top: calc(8px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--rule);
}
.search-head svg { color: var(--ink-3); }
.search-head input {
  flex: 1; min-width: 0; height: 48px;
  border: 0; background: none; outline: none;
  font-size: 18px;
}
.search-head input::-webkit-search-cancel-button { display: none; }
.search-head .text-btn { padding: 0 8px; }
.results { list-style: none; margin: 0; padding: 4px 0; }
.results a {
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; padding: 8px 16px;
}
.results a:active, .results a:hover, .results a[aria-selected="true"] { background: var(--wash); }
.results .n { font-weight: 600; }
.results .y { color: var(--ink-3); margin-left: 6px; font-variant-numeric: tabular-nums; }
.results .sub { display: block; font-size: 15px; color: var(--ink-3); }
.results mark { background: var(--lineage-wash); color: inherit; border-radius: 3px; }
.search-hint { margin: 0; padding: 12px 16px; color: var(--ink-3); font-size: 15px; }

/* ---------- öneri formu (alttan açılan sayfa) ---------- */
.sheet {
  width: 100%; max-width: 560px;
  max-height: 92dvh;
  margin: auto auto 0;
  border-radius: 20px 20px 0 0;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain;
}
@media (min-width: 700px) { .sheet { margin: auto; border-radius: 20px; padding-bottom: 20px; } }
@media (prefers-reduced-motion: no-preference) {
  .sheet[open] { animation: rise .25s cubic-bezier(.2, .7, .2, 1); }
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.sheet-head {
  position: sticky; top: 0; z-index: 1; background: var(--paper);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  padding: 18px 0 10px;
}
.sheet-head h2 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.sheet-sub { margin: 2px 0 0; color: var(--ink-2); font-size: 15px; }
.sheet-head .icon-btn { margin: -8px -8px 0 0; }
.group { margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--rule); }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.field small { display: block; margin-top: 4px; font-size: 14px; color: var(--ink-3); }
.field input, .field select, .field textarea {
  display: block; width: 100%;
  min-height: 48px; padding: 10px 12px;
  font-size: 16px;                 /* Android/iOS yakınlaştırmasın */
  background: var(--paper);
  border: 1.5px solid var(--rule); border-radius: 10px;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--lineage); outline: none; }
.field.invalid input { border-color: var(--danger); }
.warn {
  margin: 4px 0 14px; padding: 12px;
  border-radius: 10px; background: color-mix(in srgb, var(--danger) 9%, var(--paper));
  font-size: 15px;
}
.form-error { color: var(--danger); font-weight: 600; font-size: 15px; margin: 0 0 12px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.btn {
  display: block; width: 100%; min-height: 52px;
  border: 1.5px solid var(--rule); border-radius: 12px; background: var(--paper);
  font-weight: 700; font-size: 17px; cursor: pointer;
}
.btn.primary { background: var(--lineage); border-color: var(--lineage); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #08140e; } }
.btn:disabled { opacity: .6; }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.done { text-align: center; padding: 28px 8px 8px; }
.done svg { width: 48px; height: 48px; color: var(--lineage); stroke-width: 2.5; }
.done h2 { margin: 8px 0 4px; font-size: 22px; }
.done p { margin: 0 0 20px; color: var(--ink-2); }

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

/* ---------- görünüm geçişi ---------- */
.modes {
  margin-left: auto; margin-right: 4px;
  display: flex; padding: 2px; gap: 2px;
  background: var(--wash); border-radius: 999px;
}
.modes a {
  min-height: 44px; display: grid; place-items: center;
  padding: 0 16px; border-radius: 999px;
  font-size: 16px; font-weight: 600; color: var(--ink-2);
}
.modes a[aria-current="page"] { background: var(--paper); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
@media (max-width: 340px) { .home > span { display: none; } }
@media (max-width: 599px) { .home .wide { display: none; } }
.bar .icon-btn { flex: none; }

/* ---------- ağaç ---------- */
body.tree-mode .view, body.tree-mode .foot { display: none; }
body.tree-mode { overflow: hidden; height: 100dvh; overscroll-behavior: none; }
#treeSvg, .t-node { -webkit-touch-callout: none; }
.tree-view.has-card .t-tools { bottom: calc(var(--card-h, 100px) + 24px + env(safe-area-inset-bottom)); }
.tree-view {
  position: relative; flex: 1; min-height: 0;
  background: var(--wash);
  overflow: hidden;
}
#treeSvg { stroke: none; fill: none; display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
#treeSvg:active { cursor: grabbing; }

.t-link { fill: none; stroke: var(--ink-3); stroke-opacity: .55; stroke-width: 1.6; }
.t-link.on { stroke: var(--lineage); stroke-opacity: 1; stroke-width: 3.5; }
.t-node { cursor: pointer; }
.t-node rect.box { fill: var(--paper); stroke: var(--rule); stroke-width: 1.5; }
.t-node.on rect.box { stroke: var(--lineage); stroke-width: 2.5; }
.t-node.sel rect.box { fill: var(--lineage); stroke: var(--lineage); }
.t-node text { font-family: var(--font); fill: var(--ink); }
.t-node .nm { font-size: 17px; font-weight: 700; }
.t-node .yr { font-size: 15px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.t-node.sel .nm, .t-node.sel .yr { fill: #fff; }
@media (prefers-color-scheme: dark) { .t-node.sel .nm, .t-node.sel .yr { fill: #08140e; } }
.t-node .stbar { stroke: none; }
.t-node .more { cursor: pointer; }
.t-node .more .hit { fill: transparent; }
.t-node .more .pill { fill: var(--ink); stroke: var(--ink); stroke-width: 1.5; }
.t-node .more text { fill: var(--paper); font-size: 16px; font-weight: 700; }
.t-node .more.open .pill { fill: var(--paper); stroke: var(--ink-3); }
.t-node .more.open text { fill: var(--ink); font-size: 22px; }
.t-node.review rect.box { stroke-dasharray: 4 3; }
.st-fill-no_children { fill: var(--st-no_children); }
.st-fill-daughters_only { fill: var(--st-daughters_only); }
.st-fill-outside_village { fill: var(--st-outside_village); }
.st-fill-unknown_lineage { fill: var(--st-unknown_lineage); }
.dot.path { background: var(--lineage); border-radius: 2px; height: 4px; width: 16px; }

.t-tools {
  position: absolute; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom));
  display: grid; gap: 6px;
}
.t-tools .icon-btn, .t-all, .t-legend summary {
  background: var(--paper); box-shadow: 0 1px 3px rgb(0 0 0 / .14);
}
.t-tools .icon-btn { width: 44px; height: 44px; border-radius: 12px; }
.t-all {
  position: absolute; left: 12px; top: 12px;
  min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px;
  font-weight: 600; font-size: 16px; cursor: pointer;
}
.t-legend { position: absolute; left: 12px; top: 64px; max-width: calc(100% - 90px); }
.t-legend summary {
  list-style: none; display: inline-grid; place-items: center;
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  font-weight: 600; font-size: 16px; cursor: pointer;
}
.t-legend summary::-webkit-details-marker { display: none; }
.t-legend .legend {
  margin-top: 6px; padding: 12px 14px; background: var(--paper);
  border-radius: 12px; box-shadow: 0 2px 10px rgb(0 0 0 / .15);
  font-size: 15px; color: var(--ink-2);
}
.t-card {
  position: absolute; left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 12px 16px;
  background: var(--paper); border-radius: 16px;
  box-shadow: 0 4px 20px rgb(0 0 0 / .18);
}
.t-card-txt { flex: 1; min-width: 0; }
.t-card strong { display: block; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-card span { display: block; font-size: 15px; color: var(--ink-2); }
.t-card-btns { display: flex; flex-direction: column; gap: 6px; flex: none; }
.t-fold {
  min-height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid var(--rule); background: var(--paper);
  font-weight: 600; font-size: 15px; cursor: pointer;
}
.t-open {
  flex: none; min-height: 44px; display: grid; place-items: center;
  padding: 0 16px; border-radius: 12px;
  background: var(--lineage); color: #fff; font-weight: 700; font-size: 15px;
}
@media (prefers-color-scheme: dark) { .t-open { color: #08140e; } }

/* ---------- geniş ekran: solda ağaç, sağda kişi ---------- */
.side { display: none; }
@media (min-width: 960px) {
  .tree-view { display: grid; grid-template-columns: minmax(0, 1fr) 440px; grid-template-rows: minmax(0, 1fr); }
  .tree-view > #treeSvg { grid-column: 1; grid-row: 1; }
  .side {
    display: block; grid-column: 2; grid-row: 1;
    overflow-y: auto; overscroll-behavior: contain;
    background: var(--paper); border-left: 1px solid var(--rule);
    padding: 8px 20px 40px;
  }
  .side[hidden] { display: none; }
  .tree-view .t-tools { right: calc(440px + 16px); bottom: 16px; }
  .tree-view.has-card .t-tools { bottom: 16px; }
  .side .me h1 { font-size: 34px; }
}

/* ---------- yerinde çocuk ekleme ---------- */
.ghost-li { position: relative; }
.add-form, .ghost-li.done .row {
  margin-left: calc(var(--rail) + 14px);
  padding: 14px 14px 12px;
  border: 2px dashed var(--lineage); border-radius: 14px;
  background: var(--lineage-wash);
}
.ghost-li.done { display: grid; gap: 4px; }
.ghost-li.done .text-btn { margin-left: calc(var(--rail) + 14px); justify-self: start; }
.add-form .where { margin: 0 0 12px; font-size: 16px; color: var(--ink-2); }
.add-form .where b { color: var(--lineage); }
.add-form .where small { font-size: 14px; color: var(--ink-3); }
.add-form .row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0 10px; }
.add-form .field { margin-bottom: 8px; }
.add-form .hint { display: block; font-size: 14px; color: var(--ink-3); margin: 0 0 10px; }
.add-form .more-fields { margin: 0 0 8px; }
.add-form .more-fields summary { min-height: 44px; display: flex; align-items: center; color: var(--lineage); font-weight: 600; cursor: pointer; }
.add-form .group { border-top-color: color-mix(in srgb, var(--lineage) 25%, transparent); }
.add-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 6px 0 8px; }
.add-actions .btn:not(.primary) { width: auto; padding: 0 18px; }
.kids li.ghost-li::before { background: var(--lineage); height: 2px; top: 28px; }
.add-form .where { margin-bottom: 4px; }
.add-form .hint.order { margin-bottom: 14px; }

.t-node.ghost rect.box { fill: var(--lineage-wash); stroke: var(--lineage); stroke-width: 2.5; stroke-dasharray: 7 5; }
.t-node.ghost .nm { fill: var(--lineage); }
.t-link.ghost { stroke: var(--lineage); stroke-opacity: 1; stroke-width: 2.5; stroke-dasharray: 7 5; }

/* İsteğe bağlı alanlar kapalı başlar */
details.optional { margin-top: 4px; }
details.optional > summary {
  min-height: 48px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  color: var(--lineage); font-weight: 600; cursor: pointer; list-style: none;
}
details.optional > summary::-webkit-details-marker { display: none; }
details.optional > summary::before { content: "+"; font-size: 20px; width: 16px; }
details.optional[open] > summary::before { content: "−"; }
details.optional > summary small { color: var(--ink-3); font-weight: 400; font-size: 14px; }
details.optional[open] > summary { margin-bottom: 6px; }

.ghost-li.done .row { text-align: left; justify-content: flex-start; }

/* ---------- telefonda alt menü ---------- */
.tabbar { display: none; }
@media (max-width: 959px) {
  .bar .modes, .bar #openSearch { display: none; }
  .tabbar {
    position: sticky; bottom: 0; z-index: 6;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--paper) 94%, transparent);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--rule);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 58px; border: 0; border-radius: 16px; background: none;
    color: var(--ink-2); font-size: 15px; font-weight: 600; cursor: pointer;
  }
  .tabbar svg { width: 26px; height: 26px; }
  .tabbar [aria-current="page"] { background: var(--lineage-wash); color: var(--lineage); font-weight: 800; }
  .tabbar [aria-current="page"] svg { stroke-width: 2.4; }
  .tabbar a:active, .tabbar button:active { background: var(--wash); }
  .home > span, .home .wide { display: inline !important; }
}

/* ---------- onay bekleyen kendi önerilerim ---------- */
.pending-note {
  margin: 12px 0 0; padding: 10px 12px; border-radius: 0 8px 8px 0;
  border-left: 3px dashed var(--lineage); background: var(--lineage-wash);
  font-size: 15px; color: var(--ink-2);
}
.kids li.pending .row { border: 1.5px dashed var(--lineage); }
.kids li.pending .sub { color: var(--lineage); font-weight: 600; }
.chip.pending { border-style: dashed; border-color: var(--lineage); }
.t-node.pending rect.box { stroke: var(--lineage); stroke-width: 2; stroke-dasharray: 6 4; }
.t-node.pending.sel rect.box { stroke-dasharray: none; }
.dot.pend { width: 16px; height: 12px; border-radius: 3px; border: 2px dashed var(--lineage); background: none; }
.toast {
  pointer-events: none;
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(92px + env(safe-area-inset-bottom));
  width: min(520px, calc(100% - 32px));
  padding: 14px 16px; border-radius: 14px;
  background: var(--ink); color: var(--paper);
  font-size: 16px; font-weight: 500; box-shadow: 0 6px 24px rgb(0 0 0 / .25);
}
@media (min-width: 960px) { .toast { bottom: 24px; } }

/* ---------- harita ---------- */
.map-view { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
#map { flex: 1; min-height: 0; background: var(--wash); }
.map-top {
  position: absolute; z-index: 500; top: 12px; left: 12px; right: 12px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; pointer-events: none;
}
.map-top > * { pointer-events: auto; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--paper); border-radius: 999px; box-shadow: 0 1px 4px rgb(0 0 0 / .18); }
.seg button {
  min-height: 42px; padding: 0 16px; border: 0; border-radius: 999px; background: none;
  font-weight: 600; font-size: 15px; color: var(--ink-2); cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--lineage); color: #fff; }
@media (prefers-color-scheme: dark) { .seg button[aria-pressed="true"] { color: #08140e; } }
.map-check {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px;
  background: var(--paper); border-radius: 999px; box-shadow: 0 1px 4px rgb(0 0 0 / .18);
  font-weight: 600; font-size: 15px; color: var(--story); cursor: pointer;
}
.map-check input { width: 20px; height: 20px; accent-color: var(--story); }
.map-sheet {
  background: var(--paper); border-top: 1px solid var(--rule);
  max-height: 22dvh; overflow-y: auto; transition: max-height .25s ease;
}
.map-sheet.open { max-height: 55dvh; }
.map-sheet-body { padding: 12px 16px 16px; max-width: 640px; margin: 0 auto; }
.map-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.map-sheet-head h2 { margin: 0; font-size: 22px; font-weight: 800; }
.map-sum { margin: 0 0 4px; font-size: 16px; }
.map-hint { margin: 4px 0 8px; font-size: 15px; color: var(--ink-3); }
.map-list { margin-top: 4px; }
.map-list::before, .map-list li::before { display: none; }
.map-list .row { margin-left: 0; }
.story-tag { display: inline-block; margin: 6px 0 2px; padding: 2px 10px; border-radius: 999px; border: 1.5px dashed var(--story); color: var(--story); font-weight: 700; font-size: 14px; }
.map-count { display: grid !important; place-items: center; font: 800 14px var(--font); color: var(--ink); text-shadow: 0 0 3px var(--paper), 0 0 3px var(--paper); }
.leaflet-container svg { width: auto; height: auto; }   /* genel simge boyutu kuralı harita katmanını küçültmesin */
.leaflet-marker-icon.story-pin { display: grid; place-items: center; cursor: pointer; }
.story-pin i {
  display: block;
  width: 16px; height: 16px; border-radius: 4px; transform: rotate(45deg);
  background: var(--paper); border: 2.5px solid var(--story); box-shadow: 0 1px 3px rgb(0 0 0 / .25);
}
.story-pin span {
  display: none; position: absolute; left: 50%; top: 26px; transform: translateX(-50%); white-space: nowrap;
  padding: 4px 10px; border-radius: 999px; background: var(--paper);
  border: 2px dashed var(--story); color: var(--story); font: 700 14px var(--font);
  box-shadow: 0 1px 3px rgb(0 0 0 / .15); cursor: pointer;
}
.leaflet-container { font-family: var(--font); }
.leaflet-control-zoom a { width: 44px !important; height: 44px !important; line-height: 44px !important; font-size: 22px !important; }
.place-line a { display: inline-flex; align-items: center; gap: 4px; color: var(--lineage); font-weight: 600; min-height: 44px; }
.place-line svg { width: 18px; height: 18px; }
@media (min-width: 960px) {
  .map-view { flex-direction: row; }
  .map-sheet { width: 400px; max-height: none !important; border-top: 0; border-left: 1px solid var(--rule); order: 2; }
  #map { order: 1; }
  .map-top { right: calc(400px + 12px); }
}
@media (max-width: 959px) {
  .tabbar { grid-template-columns: repeat(4, 1fr); }
}

#map.zoomed .story-pin span { display: inline-block; }

@media (prefers-color-scheme: dark) { .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); } }

/* ---------- kız evlat ---------- */
.fem { color: var(--female); font-weight: 600; }
.t-node.female rect.box { stroke: var(--female); stroke-width: 2; }
.t-node.female:not(.sel) rect.box { fill: color-mix(in srgb, var(--female) 7%, var(--paper)); }
.t-node.female.sel rect.box { fill: var(--female); stroke: var(--female); }
.chip.female { border-color: color-mix(in srgb, var(--female) 55%, var(--rule)); }
.anc.female .n { color: var(--female); }
.dot.fem-dot { background: color-mix(in srgb, var(--female) 12%, var(--paper)); border: 2px solid var(--female); border-radius: 3px; width: 16px; height: 12px; }
.gender-pick { border: 0; margin: 0 0 10px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gender-pick legend { font-size: 15px; font-weight: 600; margin-bottom: 6px; padding: 0; }
.gender-pick label { position: relative; }
.gender-pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.gender-pick span {
  display: grid; place-items: center; min-height: 52px; border-radius: 12px;
  border: 2px solid var(--rule); background: var(--paper); font-weight: 700; font-size: 17px;
}
.gender-pick input:checked + span { border-color: var(--lineage); background: var(--lineage); color: #fff; }
.gender-pick input[value="K"]:checked + span { border-color: var(--female); background: var(--female); }
.gender-pick input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (prefers-color-scheme: dark) { .gender-pick input:checked + span { color: #08140e; } }

/* ---------- soy filtresi ---------- */
.tree-view > .line-filter { position: absolute; top: 12px; right: 12px; z-index: 5; }
.seg.line-filter button { min-height: 44px; padding: 0 14px; }
@media (min-width: 960px) { .tree-view > .line-filter { right: calc(440px + 12px); } }
@media (max-width: 380px) { .tree-view > .line-filter { top: 116px; left: 12px; right: auto; } }

.privacy-note { margin: 12px 0 0; padding: 10px 12px; border-radius: 0 8px 8px 0; border-left: 3px solid var(--ink-3); background: var(--wash); font-size: 15px; color: var(--ink-2); max-width: 34em; }
.check-line { display: flex; align-items: center; gap: 10px; min-height: 48px; font-size: 16px; font-weight: 600; }
.check-line input { width: 22px; height: 22px; accent-color: var(--lineage); }

.cal-hint { margin-top: 6px; padding: 8px 10px; border-radius: 10px; border: 1.5px dashed var(--story, #9a5b13); font-size: 14px; display: grid; gap: 6px; }
.cal-hint span { color: var(--ink-2); }
.cal-hint button { text-align: left; min-height: 40px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--rule, var(--line)); background: var(--paper, var(--surface)); font: inherit; color: inherit; cursor: pointer; }
.cal-hint button b { color: var(--lineage, var(--path)); margin-left: 6px; }
@media (max-width: 520px) { .add-form .row2 { grid-template-columns: 1fr; } }
/* Alt menü kaydırmada düğmelerin üstüne binmesin */
@media (max-width: 959px) { html { scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom)); scroll-padding-top: 64px; } }

.field.is-hidden-val input::placeholder { color: var(--lineage); opacity: .9; font-weight: 600; }
#hiddenInfo { margin: 0 0 12px; }

/* ---------- istenmeyen yakınlaşmalar ----------
   Ağaç ve harita ekranlarında sayfa yakınlaşmaz; iki parmak yalnızca ağacı/haritayı büyütür.
   Diğer sayfalarda okumak için iki parmakla büyütme açık, çift dokunuşla yakınlaşma kapalı. */
html { touch-action: manipulation; }
body.tree-mode .bar, body.tree-mode .tabbar, .tree-view, .tree-view *, .map-view .map-top, .map-view .map-top * { touch-action: none; }
#map, .leaflet-container { touch-action: none; }
.map-sheet { touch-action: pan-y; }
.t-legend .legend { touch-action: pan-y; }
input, select, textarea { font-size: max(16px, 1em); }   /* iPhone'da yazarken sayfa büyümesin */
