/* FamTree plugin styles. Colours come from CSS variables so the theme (or any other theme) can restyle them.
   Dark mode: every text colour has a tested contrast of at least 4.5:1 against its background. */
:root {
  --ft-bg: #f6f7f4; --ft-surface: #ffffff; --ft-surface-2: #eef1ec; --ft-text: #16221d; --ft-muted: #4d5b54;
  --ft-border: #d5dcd5; --ft-primary: #1f6b55; --ft-primary-text: #ffffff; --ft-accent: #b4541f; --ft-accent-text: #ffffff;
  --ft-danger: #a82424; --ft-ok-bg: #e3f4ea; --ft-ok-text: #11502d; --ft-err-bg: #fbe7e7; --ft-err-text: #7a1717;
  --ft-focus: #1f6b55; --ft-radius: 14px; --ft-shadow: 0 1px 2px rgba(20,40,30,.06), 0 8px 24px rgba(20,40,30,.06);
}
:root[data-theme="dark"] {
  --ft-bg: #0f1613; --ft-surface: #18211d; --ft-surface-2: #212c27; --ft-text: #eef3ef; --ft-muted: #b4c2ba;
  --ft-border: #34443c; --ft-primary: #5fd0a6; --ft-primary-text: #06201a; --ft-accent: #ffa56b; --ft-accent-text: #2a1204;
  --ft-danger: #ff8d8d; --ft-ok-bg: #123524; --ft-ok-text: #bff0d3; --ft-err-bg: #3b1a1a; --ft-err-text: #ffc9c9;
  --ft-focus: #8be3c1; --ft-shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

.ft-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ft-hp { position: absolute !important; left: -9999px; height: 0; overflow: hidden; }
.ft-prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.ft-muted { color: var(--ft-muted); }
.ft-small { font-size: .85rem; }
.ft-loading { color: var(--ft-muted); padding: 24px 0; }

/* ---- buttons */
.ft-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 999px; border: 1.5px solid transparent;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; line-height: 1.2; transition: transform .12s, box-shadow .12s, background .12s; }
.ft-btn:hover { transform: translateY(-1px); }
.ft-btn:disabled { opacity: .6; cursor: progress; transform: none; }
.ft-btn--primary { background: var(--ft-primary); color: var(--ft-primary-text); }
.ft-btn--accent { background: var(--ft-accent); color: var(--ft-accent-text); }
.ft-btn--ghost { background: transparent; color: var(--ft-text); border-color: var(--ft-border); }
.ft-btn--ghost:hover { background: var(--ft-surface-2); }
.ft-btn--danger { background: transparent; color: var(--ft-danger); border-color: var(--ft-danger); }
.ft-btn--block { width: 100%; }
.ft-btn--icon { min-width: 42px; padding: 10px 12px; font-size: 1.1rem; }
.ft-link { background: none; border: 0; padding: 0; color: var(--ft-primary); font: inherit; text-decoration: underline; cursor: pointer; }
:where(.ft-btn, .ft-link, .ft-chip, .ft-node, .ft-svg, .ft-grid__btn, input, select, textarea):focus-visible { outline: 3px solid var(--ft-focus); outline-offset: 2px; }

/* ---- forms */
.ft-form { background: var(--ft-surface); color: var(--ft-text); border: 1px solid var(--ft-border); border-radius: var(--ft-radius); padding: 24px; box-shadow: var(--ft-shadow); }
.ft-form--inline { background: transparent; border: 0; padding: 0; box-shadow: none; }
.ft-form__title { margin: 0 0 4px; font-size: 1.4rem; color: var(--ft-text); }
.ft-form__sub { margin: 0 0 16px; color: var(--ft-muted); }
.ft-form__foot { text-align: center; margin: 14px 0 0; font-size: .9rem; }
.ft-form a { color: var(--ft-primary); }
.ft-field { display: block; margin: 0 0 14px; }
.ft-field > span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; color: var(--ft-text); }
.ft-field input, .ft-field select, .ft-field textarea, .ft-inline-form textarea, .ft-search, .ft-chips + .ft-field input {
  width: 100%; box-sizing: border-box; padding: 11px 13px; border-radius: 10px; border: 1.5px solid var(--ft-border);
  background: var(--ft-surface); color: var(--ft-text); font: inherit; }
.ft-field input::placeholder, .ft-field textarea::placeholder, .ft-search::placeholder, .ft-inline-form textarea::placeholder { color: var(--ft-muted); opacity: 1; }
.ft-field input:focus, .ft-field select:focus, .ft-field textarea:focus { border-color: var(--ft-primary); }
.ft-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ft-check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 16px; color: var(--ft-text); font-size: .92rem; line-height: 1.4; }
.ft-check input { margin-top: 3px; accent-color: var(--ft-primary); width: 18px; height: 18px; flex: none; }
.ft-check--box { border: 1.5px solid var(--ft-border); border-radius: 12px; padding: 12px 14px; align-items: center; margin-bottom: 8px; }
.ft-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.ft-fieldset { border: 0; padding: 0; margin: 0 0 14px; }
.ft-fieldset legend { font-weight: 700; margin-bottom: 8px; color: var(--ft-text); padding: 0; }

/* ---- notices */
.ft-notice { padding: 12px 16px; border-radius: 12px; margin: 0 0 14px; font-weight: 500; }
.ft-notice--ok { background: var(--ft-ok-bg); color: var(--ft-ok-text); }
.ft-notice--err { background: var(--ft-err-bg); color: var(--ft-err-text); }
.ft-gate { max-width: 460px; margin: 0 auto; }
.ft-gate > p { color: var(--ft-muted); text-align: center; }

/* ---- cards / profile */
.ft-card { background: var(--ft-surface); color: var(--ft-text); border: 1px solid var(--ft-border); border-radius: var(--ft-radius); padding: 20px; margin: 0 0 16px; box-shadow: var(--ft-shadow); }
.ft-card h3 { margin-top: 0; }
.ft-profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.ft-profile-head h3 { margin: 0 0 4px; }
.ft-profile-head p { margin: 0; }
.ft-avatar { border-radius: 50%; object-fit: cover; flex: none; background: var(--ft-surface-2); }
.ft-avatar--init { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--ft-primary); border: 2px solid var(--ft-border); }
.ft-list { margin: 0; padding-left: 18px; }

/* ---- tree */
.ft-tree__bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.ft-search { flex: 1 1 200px; max-width: 320px; width: auto; border-radius: 999px; }
.ft-tree__layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.ft-tree__stage { position: relative; height: min(72vh, 680px); min-height: 380px; background: var(--ft-surface); border: 1px solid var(--ft-border); border-radius: var(--ft-radius); overflow: hidden;
  background-image: radial-gradient(var(--ft-border) 1px, transparent 1px); background-size: 22px 22px; box-shadow: var(--ft-shadow); }
.ft-svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; user-select: none; }
.ft-svg:active { cursor: grabbing; }
.ft-svg__empty { fill: var(--ft-muted); font-size: 18px; }
.ft-tree__panel { background: var(--ft-surface); color: var(--ft-text); border: 1px solid var(--ft-border); border-radius: var(--ft-radius); padding: 18px; box-shadow: var(--ft-shadow); max-height: min(72vh, 680px); overflow: auto; }
.ft-edge { fill: none; stroke: var(--ft-muted); stroke-width: 2; opacity: .75; }
.ft-edge.is-spouse { stroke: var(--ft-accent); stroke-dasharray: 0; opacity: 1; }
.ft-edge.is-pending { stroke-dasharray: 6 5; opacity: .55; }
.ft-node { cursor: pointer; outline: none; }
.ft-node__bg { fill: var(--ft-surface); stroke: var(--ft-border); stroke-width: 1.5; }
.ft-node__bar { fill: var(--ft-muted); }
.ft-node.g-m .ft-node__bar { fill: #4a8fd6; } .ft-node.g-f .ft-node__bar { fill: #d6609a; } .ft-node.g-o .ft-node__bar { fill: #8a6fd6; }
.ft-node__avatar { fill: var(--ft-surface-2); stroke: var(--ft-border); }
.ft-node__init { fill: var(--ft-primary); font-weight: 700; font-size: 16px; }
.ft-node__name { fill: var(--ft-text); font-weight: 700; font-size: 14px; }
.ft-node__years { fill: var(--ft-muted); font-size: 12px; }
.ft-node__you { fill: var(--ft-accent); font-size: 11px; font-weight: 700; }
.ft-node:hover .ft-node__bg, .ft-node:focus-visible .ft-node__bg { stroke: var(--ft-primary); }
.ft-node.is-selected .ft-node__bg { stroke: var(--ft-primary); stroke-width: 3; }
.ft-node.is-me .ft-node__bg { fill: var(--ft-surface-2); }
.ft-node.is-hit .ft-node__bg { stroke: var(--ft-accent); stroke-width: 3.5; }

/* ---- comments, chat */
.ft-comments { margin-top: 18px; border-top: 1px solid var(--ft-border); padding-top: 12px; }
.ft-comments h4 { margin: 0 0 8px; }
.ft-comments__list { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 10px; }
.ft-comments__meta, .ft-msg__meta { font-size: .8rem; color: var(--ft-muted); }
.ft-comments__meta b, .ft-msg__meta b { color: var(--ft-text); }
.ft-inline-form { display: flex; gap: 8px; align-items: flex-end; }
.ft-inline-form textarea { flex: 1; resize: vertical; min-height: 44px; }
.ft-chat__list { height: min(55vh, 520px); overflow-y: auto; background: var(--ft-surface); border: 1px solid var(--ft-border); border-radius: var(--ft-radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.ft-msg { max-width: 78%; align-self: flex-start; background: var(--ft-surface-2); color: var(--ft-text); border-radius: 16px 16px 16px 4px; padding: 9px 13px; }
.ft-msg.is-mine { align-self: flex-end; background: var(--ft-primary); color: var(--ft-primary-text); border-radius: 16px 16px 4px 16px; }
.ft-msg.is-mine .ft-msg__meta, .ft-msg.is-mine .ft-msg__meta b, .ft-msg.is-mine .ft-link { color: var(--ft-primary-text); }

/* ---- gallery */
.ft-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.ft-grid__item { margin: 0; background: var(--ft-surface); border: 1px solid var(--ft-border); border-radius: 12px; overflow: hidden; }
.ft-grid__btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.ft-grid__item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.ft-grid__item figcaption { display: flex; justify-content: space-between; padding: 8px 10px; font-size: .85rem; color: var(--ft-muted); }
.ft-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 99999; padding: 20px; cursor: zoom-out; }
.ft-lightbox img { max-width: 100%; max-height: 82vh; border-radius: 8px; }
.ft-lightbox p { color: #fff; margin-top: 10px; }

/* ---- donate */
#ft-donate { max-width: 560px; }
.ft-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ft-chip { padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--ft-border); background: var(--ft-surface); color: var(--ft-text); font: inherit; font-weight: 600; cursor: pointer; }
.ft-chip[aria-pressed="true"] { background: var(--ft-primary); color: var(--ft-primary-text); border-color: var(--ft-primary); }

/* ---- weather, language */
.ft-wx { display: flex; gap: 14px; align-items: center; }
.ft-wx__icon { font-size: 2.6rem; line-height: 1; }
.ft-wx__temp { font-size: 1.8rem; font-weight: 700; }
.ft-weather--chip { display: inline-flex; gap: 4px; align-items: center; font-weight: 600; }
.ft-lang ul { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; flex-wrap: wrap; }
.ft-lang a { display: inline-block; padding: 6px 10px; border-radius: 999px; font-size: .85rem; font-weight: 700; text-decoration: none; color: var(--ft-text); border: 1.5px solid var(--ft-border); background: var(--ft-surface); }
.ft-lang a:hover { border-color: var(--ft-primary); }
.ft-lang a.is-active { background: var(--ft-primary); color: var(--ft-primary-text); border-color: var(--ft-primary); }

@media (max-width: 900px) { .ft-tree__layout { grid-template-columns: 1fr; } .ft-tree__panel { max-height: none; } }
@media (max-width: 520px) { .ft-row { grid-template-columns: 1fr; } .ft-msg { max-width: 92%; } }
@media (prefers-reduced-motion: reduce) { .ft-btn { transition: none; } .ft-btn:hover { transform: none; } }

/* ---- live language switch: text fades out, is swapped, fades back in */
[data-i18n], .ft-app, [data-ft-weather] { transition: opacity .18s ease; }
html.ft-i18n-out [data-i18n], html.ft-i18n-out .ft-app, html.ft-i18n-out [data-ft-weather] { opacity: 0; }
@media (prefers-reduced-motion: reduce) { [data-i18n], .ft-app, [data-ft-weather] { transition: none; } }

/* ---- lightbox close button */
.ft-lightbox__close { position: absolute; top: max(14px, env(safe-area-inset-top, 0px)); right: max(14px, env(safe-area-inset-right, 0px)); width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.6); background: rgba(0,0,0,.45); color: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.ft-lightbox__close:hover { background: rgba(255,255,255,.18); }
