/* ============================================================
   Kin — family register
   Heritage theme: warm parchment, forest green, antique gold
   ============================================================ */

:root {
    --bg:        #f4efe6;
    --bg-grain:  #efe8da;
    --surface:   #fffdf8;
    --surface-2: #faf6ed;
    --ink:       #2a2520;
    --ink-soft:  #4f463c;
    --muted:     #938777;
    --line:      #e4dac8;
    --line-soft: #efe7d8;

    --green:     #1f5d4c;
    --green-d:   #154233;
    --gold:      #b88a2e;
    --gold-soft: #d8b25a;
    --rose:      #9a3b4c;
    --blue:      #2f6f8f;

    --ok-bg:     #e8f1ea;  --ok-ink: #1f5d4c;
    --err-bg:    #f7e7e6;  --err-ink:#9a3b3b;

    --radius:    14px;
    --radius-sm: 9px;
    --shadow:    0 1px 2px rgba(42,37,32,.04), 0 8px 24px -12px rgba(42,37,32,.18);
    --shadow-lg: 0 2px 6px rgba(42,37,32,.06), 0 24px 48px -20px rgba(42,37,32,.30);
    --ring:      0 0 0 3px rgba(31,93,76,.16);

    --serif: "Fraunces", Georgia, "Times New Roman", serif;
    --sans:  "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--sans);
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 100% -10%, rgba(184,138,46,.06), transparent 60%),
        radial-gradient(900px 500px at -10% 0%, rgba(31,93,76,.06), transparent 55%),
        var(--bg);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }

/* ----------------------------- top bar ----------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 40;
    background: rgba(255,253,248,.82);
    backdrop-filter: saturate(150%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.topbar__inner {
    max-width: 1180px; margin: 0 auto; padding: 0 22px;
    height: 64px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand__mark { color: var(--gold); font-size: 22px; transform: translateY(2px); }
.brand__name { font-family: var(--serif); font-weight: 700; font-size: 22px; }
.brand__sub  { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav__link {
    padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 14px;
    color: var(--ink-soft); transition: .15s;
}
.nav__link:hover { background: var(--surface-2); color: var(--ink); }
.nav__link.is-active { background: var(--green); color: #fff; }

/* ----------------------------- layout ----------------------------- */
.page { max-width: 1180px; width: 100%; margin: 0 auto; padding: 34px 22px 60px; flex: 1; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head__eyebrow { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.page-head h1 { font-size: clamp(26px, 4vw, 38px); margin-top: 4px; }
.page-head p { color: var(--muted); margin: 6px 0 0; }

.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 26px; border-top: 1px solid var(--line-soft); }

/* ----------------------------- flash ----------------------------- */
.flash {
    max-width: 1180px; margin: 16px auto 0; padding: 12px 18px; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 14px; box-shadow: var(--shadow);
    width: calc(100% - 44px);
}
.flash--ok  { background: var(--ok-bg);  color: var(--ok-ink);  border: 1px solid #cfe3d4; }
.flash--err { background: var(--err-bg); color: var(--err-ink); border: 1px solid #eccfcd; }

/* ----------------------------- buttons ----------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    font-family: var(--sans); font-weight: 600; font-size: 14.5px;
    padding: 10px 18px; border-radius: 11px; border: 1px solid transparent;
    cursor: pointer; transition: .15s; white-space: nowrap; background: none; color: inherit;
}
.btn--sm { padding: 8px 14px; font-size: 13.5px; border-radius: 9px; }
.btn--primary { background: var(--green); color: #fff; box-shadow: 0 6px 16px -8px rgba(31,93,76,.6); }
.btn--primary:hover { background: var(--green-d); }
.btn--gold { background: var(--gold); color: #fff; }
.btn--gold:hover { filter: brightness(.95); }
.btn--ghost { background: var(--surface); border-color: var(--line); color: var(--ink-soft); }
.btn--ghost:hover { border-color: var(--gold-soft); color: var(--ink); }
.btn--danger { background: transparent; color: var(--err-ink); border-color: #eccfcd; }
.btn--danger:hover { background: var(--err-bg); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ----------------------------- cards ----------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card__pad { padding: 22px; }
.card__head { padding: 18px 22px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card__head h2 { font-size: 18px; }

.grid { display: grid; gap: 18px; }

/* ----------------------------- avatars ----------------------------- */
.avatar {
    --s: 48px; width: var(--s); height: var(--s); border-radius: 50%;
    object-fit: cover; flex: none; background: var(--surface-2);
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--serif); font-weight: 600; color: #fff; overflow: hidden;
    border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ----------------------------- dashboard ----------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.stat {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 20px; position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.stat::after { content: ""; position: absolute; inset: 0 0 auto auto; width: 80px; height: 80px;
    background: radial-gradient(circle at 70% 30%, rgba(184,138,46,.14), transparent 70%); }
.stat__num { font-family: var(--serif); font-size: 38px; font-weight: 600; line-height: 1; }
.stat__label { color: var(--muted); font-size: 13px; margin-top: 8px; font-weight: 600; letter-spacing: .02em; }
.stat--green .stat__num { color: var(--green); }
.stat--gold  .stat__num { color: var(--gold); }
.stat--rose  .stat__num { color: var(--rose); }
.stat--blue  .stat__num { color: var(--blue); }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

.person-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.person-row:last-child { border-bottom: 0; }
.person-row__name { font-weight: 600; }
.person-row__meta { color: var(--muted); font-size: 13px; }
.person-row__meta a { color: var(--green); font-weight: 600; }

/* ----------------------------- table ----------------------------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.input, .select, textarea.input {
    font-family: var(--sans); font-size: 14.5px; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 13px; transition: .15s; width: 100%;
}
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--green); box-shadow: var(--ring); }
.search { min-width: 240px; }
.search-wrap { position: relative; }
.search-wrap .input { padding-left: 36px; }
.search-wrap::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 18px; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); min-width: 720px; }
table.data thead th {
    text-align: left; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
    color: var(--muted); font-weight: 700; padding: 14px 16px; background: var(--surface-2);
    border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data thead th a { color: inherit; display: inline-flex; gap: 5px; align-items: center; }
table.data thead th a:hover { color: var(--ink); }
table.data tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }
.cell-name { display: flex; align-items: center; gap: 12px; }
.cell-name a { font-weight: 600; }
.cell-name small { display: block; color: var(--muted); font-weight: 500; }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
    padding: 4px 10px; border-radius: 999px; letter-spacing: .02em; }
.pill--living  { background: #e8f1ea; color: var(--green); }
.pill--dec     { background: #efe9e2; color: var(--ink-soft); }
.pill--male    { background: #e7eff4; color: var(--blue); }
.pill--female  { background: #f7e9ec; color: var(--rose); }
.pill--other   { background: #efe9e2; color: var(--ink-soft); }
.pill--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); cursor: pointer; transition: .15s; }
.icon-btn:hover { border-color: var(--gold-soft); color: var(--ink); }
.icon-btn--danger:hover { border-color: #eccfcd; color: var(--err-ink); background: var(--err-bg); }

/* pagination */
.pagination { display: flex; gap: 6px; list-style: none; padding: 0; margin: 20px 0 0; justify-content: center; flex-wrap: wrap; }
.pagination a, .pagination span { display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0 10px;
    border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; color: var(--ink-soft); }
.pagination .active span { background: var(--green); color: #fff; border-color: var(--green); }
.pagination [aria-disabled] { opacity: .4; }

/* ----------------------------- forms ----------------------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 680px) { .form-grid { grid-template-columns: 1fr; } }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--ink-soft); }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.field .err { color: var(--err-ink); font-size: 12.5px; margin-top: 5px; font-weight: 600; }
textarea.input { resize: vertical; min-height: 96px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch__track { width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; transition: .2s; flex: none; }
.switch__track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + .switch__track { background: var(--green); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }

.photo-field { display: flex; align-items: center; gap: 16px; }
.photo-preview { width: 88px; height: 88px; border-radius: 18px; object-fit: cover; background: var(--surface-2);
    border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 12px; overflow: hidden; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ----------------------------- person detail ----------------------------- */
.profile { display: grid; grid-template-columns: 300px 1fr; gap: 22px; align-items: start; }
@media (max-width: 860px) { .profile { grid-template-columns: 1fr; } }
.profile-card { text-align: center; padding: 28px 22px; }
.profile-card .avatar { --s: 132px; font-size: 42px; margin: 0 auto 16px; }
.profile-card h1 { font-size: 26px; }
.profile-card .maiden { color: var(--muted); font-size: 14px; margin-top: 2px; }
.profile-card .years { color: var(--gold); font-weight: 700; margin-top: 8px; letter-spacing: .03em; }
.profile-tags { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 14px 0 4px; }

.facts { list-style: none; padding: 0; margin: 0; }
.facts li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: 14.5px; }
.facts li:last-child { border-bottom: 0; }
.facts .k { color: var(--muted); min-width: 120px; font-weight: 600; }
.facts .v { color: var(--ink); }
.bio { white-space: pre-wrap; color: var(--ink-soft); }

.rel-list { display: flex; flex-direction: column; gap: 0; }
.rel-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.rel-item:last-child { border-bottom: 0; }
.rel-item__label { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; color: #fff; white-space: nowrap; }
.rel-item__name { font-weight: 600; }
.rel-item__name small { display: block; color: var(--muted); font-weight: 500; }
.rel-item form { margin-left: auto; }

.add-rel { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 620px) { .add-rel { grid-template-columns: 1fr; } }

/* ----------------------------- relations master ----------------------------- */
.rel-group { margin-bottom: 26px; }
.rel-group__title { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 17px; margin-bottom: 12px; }
.rel-group__title .dot { width: 10px; height: 10px; border-radius: 50%; }
.chip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.rel-chip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 14px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); }
.rel-chip__name { font-weight: 700; }
.rel-chip__meta { color: var(--muted); font-size: 12.5px; }
.rel-chip__actions { margin-left: auto; display: flex; gap: 4px; }

/* ============================================================
   FAMILY TREE  — CSS org-chart with couple nodes + connectors
   ============================================================ */
.tree-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tree-toolbar form { display: flex; align-items: center; gap: 10px; }
.zoom-ctrl { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); margin-left: auto; }
.zoom-ctrl button { width: 38px; height: 38px; border: 0; background: none; cursor: pointer; font-size: 18px; color: var(--ink-soft); border-right: 1px solid var(--line); }
.zoom-ctrl button:last-child { border-right: 0; }
.zoom-ctrl button:hover { background: var(--surface-2); }

.tree-stage {
    border: 1px solid var(--line); border-radius: var(--radius); background:
        linear-gradient(var(--line-soft) 1px, transparent 1px) 0 0 / 26px 26px,
        linear-gradient(90deg, var(--line-soft) 1px, transparent 1px) 0 0 / 26px 26px,
        var(--surface-2);
    box-shadow: var(--shadow); overflow: auto; cursor: grab; height: min(72vh, 760px);
    -webkit-overflow-scrolling: touch;
}
.tree-stage.is-panning { cursor: grabbing; }
.tree-canvas { padding: 48px; width: max-content; transform-origin: top center; transition: transform .12s ease-out; }

/* nested list org-chart */
.tree, .tree ul { display: flex; padding: 0; margin: 0; list-style: none; justify-content: center; }
.tree ul { padding-top: 26px; position: relative; }
.tree li { position: relative; padding: 26px 10px 0; text-align: center; }

/* connector lines */
.tree li::before, .tree li::after {
    content: ""; position: absolute; top: 0; right: 50%;
    border-top: 2px solid var(--gold-soft); width: 50%; height: 26px;
}
.tree li::after { right: auto; left: 50%; border-left: 2px solid var(--gold-soft); }
.tree li:only-child::before, .tree li:only-child::after { display: none; }
.tree li:only-child { padding-top: 0; }
.tree li:first-child::before, .tree li:last-child::after { border: 0; }
.tree li:last-child::before { border-right: 2px solid var(--gold-soft); border-radius: 0 8px 0 0; }
.tree li:first-child::after { border-radius: 8px 0 0 0; }
.tree ul ul::before {
    content: ""; position: absolute; top: 0; left: 50%;
    border-left: 2px solid var(--gold-soft); width: 0; height: 26px;
}

/* the couple node */
.couple { display: inline-flex; align-items: stretch; gap: 0; }
.union-link { width: 26px; align-self: center; height: 2px; background: var(--rose); }

.node {
    display: inline-flex; flex-direction: column; align-items: center; gap: 8px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    padding: 14px 16px 13px; min-width: 132px; box-shadow: var(--shadow);
    transition: .15s; position: relative;
}
.node:hover { border-color: var(--gold-soft); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.node .avatar { --s: 58px; font-size: 20px; }
.node__name { font-family: var(--serif); font-weight: 600; font-size: 15px; line-height: 1.2; }
.node__years { font-size: 11.5px; color: var(--muted); }
.node__sex { position: absolute; top: 10px; right: 10px; width: 8px; height: 8px; border-radius: 50%; }
.node__sex--male { background: var(--blue); }
.node__sex--female { background: var(--rose); }
.node__sex--other { background: var(--muted); }
.node--deceased { background: var(--surface-2); }
.node--deceased .node__name { color: var(--ink-soft); }
.node--root { border-color: var(--green); box-shadow: 0 0 0 2px rgba(31,93,76,.18), var(--shadow); }

.tree-empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.tree-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: 13px; }
.tree-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tree-legend .swatch { width: 12px; height: 12px; border-radius: 50%; }

/* empty states */
.empty { text-align: center; padding: 70px 24px; color: var(--muted); }
.empty__mark { font-size: 46px; color: var(--gold-soft); }
.empty h3 { font-family: var(--serif); font-size: 22px; color: var(--ink); margin: 10px 0 6px; }

@media (max-width: 600px) {
    .topbar__inner { gap: 12px; }
    .brand__sub { display: none; }
    .nav { order: 3; width: 100%; margin: 0; overflow-x: auto; }
    .topbar__inner { height: auto; flex-wrap: wrap; padding: 10px 16px; }
}

/* ============================================================== */
/*  Auth · user menu · roles · danger zone (added)                */
/* ============================================================== */

/* --- topbar user area --- */
.topbar__user { display: flex; align-items: center; gap: 12px; margin-left: 14px; }

.usermenu { position: relative; }
.usermenu__btn {
    display: flex; align-items: center; gap: 9px; cursor: pointer;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 999px; padding: 5px 10px 5px 6px; font: inherit; color: var(--ink);
}
.usermenu__btn:hover { border-color: var(--gold-soft); }
.usermenu__avatar {
    width: 30px; height: 30px; border-radius: 50%; flex: none;
    display: grid; place-items: center; background: var(--green); color: #fff;
    font-weight: 700; font-size: 13px;
}
.usermenu__meta { display: flex; flex-direction: column; line-height: 1.1; text-align: left; }
.usermenu__name { font-weight: 600; font-size: 13.5px; }
.usermenu__role { font-size: 11px; color: var(--muted); }
.usermenu__chev { color: var(--muted); font-size: 11px; }
.usermenu__pop {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
    min-width: 200px; background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; box-shadow: var(--shadow-lg); padding: 8px;
}
.usermenu__email { padding: 6px 10px 10px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; word-break: break-all; }
.usermenu__pop a, .usermenu__signout {
    display: block; width: 100%; text-align: left; padding: 8px 10px;
    border-radius: 8px; font: inherit; font-size: 14px; color: var(--ink-soft);
    background: none; border: 0; cursor: pointer;
}
.usermenu__pop a:hover, .usermenu__signout:hover { background: var(--surface-2); color: var(--ink); }
.usermenu__signout { color: var(--rose); font-weight: 600; }

/* --- role pills --- */
.role-pill--admin  { background: #efe3c8; color: #7a5b16; }
.role-pill--editor { background: #e8f1ea; color: var(--green); }
.role-pill--viewer { background: #efe9e2; color: var(--ink-soft); }

/* --- danger zone --- */
.danger-zone { border-color: #eccfcd; }
.danger-zone .card__head { border-bottom-color: #f0dad8; }
.danger-zone .card__head h2 { color: var(--rose); }

/* --- login page --- */
.auth-body {
    min-height: 100vh; display: grid; place-items: center; padding: 28px;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(184,138,46,.10), transparent 60%),
        var(--bg);
}
.auth-shell { width: 100%; max-width: 400px; text-align: center; }
.auth-brand { display: inline-flex; align-items: baseline; gap: 8px; }
.auth-brand .brand__name { font-family: var(--serif); font-weight: 700; font-size: 30px; }
.auth-brand .brand__mark { color: var(--gold); font-size: 26px; }
.auth-tag { color: var(--muted); margin: 6px 0 22px; font-size: 14px; }
.auth-card { padding: 28px; text-align: left; }
.auth-title { font-size: 22px; }
.auth-sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 18px; }
.auth-form .field { margin-bottom: 14px; }
.auth-foot { margin-top: 22px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }

@media (max-width: 720px) {
    .usermenu__meta { display: none; }
    .topbar__user { margin-left: 8px; }
}

/* ============================================================== */
/*  Language toggle + Malayalam typography (added)                */
/* ============================================================== */

.lang-toggle {
    display: inline-flex; align-items: center; gap: 2px;
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 999px; padding: 2px;
}
.lang-toggle a {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 26px; padding: 0 8px;
    border-radius: 999px; font-size: 12.5px; font-weight: 700;
    color: var(--muted); text-decoration: none; line-height: 1;
}
.lang-toggle a.is-active { background: var(--green); color: #fff; }
.lang-toggle a:not(.is-active):hover { color: var(--ink); }
.lang-toggle--center { justify-content: center; margin: 18px auto 0; }

/* Malayalam needs a script-aware face; Noto carries Latin too, so names
   in either script render cleanly. Display headings use the serif Malayalam. */
.lang-ml,
.lang-ml .input,
.lang-ml .select,
.lang-ml textarea.input,
.lang-ml .btn { font-family: "Noto Sans Malayalam", var(--sans); }

.lang-ml h1,
.lang-ml h2,
.lang-ml h3,
.lang-ml .brand__name,
.lang-ml .stat__num { font-family: "Noto Serif Malayalam", var(--serif); }

/* A single field can opt into Malayalam regardless of UI language
   (used by the relation "Name (Malayalam)" input). */
input.lang-ml, .input.lang-ml { font-family: "Noto Sans Malayalam", var(--sans); }

/* Malayalam glyphs are tall — give rows a touch more breathing room. */
.lang-ml .nav__link { letter-spacing: 0; }
.lang-ml .data th, .lang-ml .data td { line-height: 1.5; }

/* ============================================================== */
/*  Tools, search, theme toggle, dark mode, print (added)         */
/* ============================================================== */

/* --- top-bar search --- */
.topbar-search input {
    width: 150px; max-width: 30vw; height: 34px; padding: 0 12px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface-2); color: var(--ink); font: inherit; font-size: 13.5px;
}
.topbar-search input:focus { outline: none; border-color: var(--green); box-shadow: var(--ring); }

/* --- theme toggle button --- */
.theme-btn {
    display: inline-grid; place-items: center; width: 32px; height: 32px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2);
    color: var(--ink-soft); text-decoration: none; font-size: 15px;
}
.theme-btn:hover { border-color: var(--gold-soft); color: var(--ink); }

/* --- "More" nav dropdown --- */
.nav-more { display: inline-block; }
.nav-more > .nav__link { cursor: pointer; background: none; border: 0; font: inherit; }

/* --- kinship finder --- */
.kinship-sentence { font-family: var(--serif); font-size: 22px; line-height: 1.35; margin: 0 0 16px; }
.kinship-path { border-top: 1px solid var(--line-soft); padding-top: 14px; }
.kinship-chain { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.kinship-node a { font-weight: 600; }
.kinship-arrow { color: var(--muted); font-size: 13px; }
.kinship-arrow em { color: var(--gold); font-style: normal; font-weight: 700; }

/* --- duplicates --- */
.dup-group { margin-bottom: 12px; }
.dup-item { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.dup-item + .dup-item { border-top: 1px solid var(--line-soft); }

/* --- inline quick-add --- */
.quick-add { margin-top: 16px; border-top: 1px solid var(--line-soft); padding-top: 14px; }
.quick-add > summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--green); list-style: none; }
.quick-add > summary::-webkit-details-marker { display: none; }
.quick-add > summary::before { content: "＋ "; color: var(--gold); font-weight: 700; }
.quick-add[open] > summary::before { content: "− "; }

/* ============================================================== */
/*  Dark mode — heritage palette, candle-lit                       */
/* ============================================================== */
.theme-dark {
    --bg:        #1a1713;
    --bg-grain:  #1f1b16;
    --surface:   #241f1a;
    --surface-2: #2b2620;
    --ink:       #f0e9dd;
    --ink-soft:  #cdc3b3;
    --muted:     #9b9180;
    --line:      #3a332b;
    --line-soft: #2f2922;

    --green:     #5fae93;
    --green-d:   #4f9a80;
    --gold:      #d8b25a;
    --gold-soft: #b88a2e;
    --rose:      #d98a98;
    --blue:      #7fb4cf;

    --ok-bg:     #1e3a30;  --ok-ink: #8fd3b8;
    --err-bg:    #3a2422;  --err-ink:#e7a59f;

    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.6);
    --shadow-lg: 0 2px 6px rgba(0,0,0,.4), 0 24px 48px -20px rgba(0,0,0,.7);
    --ring:      0 0 0 3px rgba(95,174,147,.25);
}
.theme-dark .btn--primary { box-shadow: 0 6px 16px -8px rgba(0,0,0,.7); }
.theme-dark .pill--living { background: #1e3a30; color: #8fd3b8; }
.theme-dark .pill--male   { background: #1f3340; color: #9fc8de; }
.theme-dark .pill--female { background: #3a2630; color: #e3a6b3; }
.theme-dark .node, .theme-dark .data, .theme-dark .card { background: var(--surface); }

/* ============================================================== */
/*  Print — clean profile / page output                           */
/* ============================================================== */
@media print {
    .topbar, .footer, .toolbar, .tree-toolbar, .zoom-ctrl,
    .no-print, .row-actions, .form-actions, .quick-add,
    .lang-toggle, .theme-btn, .topbar-search, .usermenu { display: none !important; }

    body { background: #fff; color: #000; }
    .page { padding: 0; max-width: none; }
    .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
    a { color: #000; text-decoration: none; }
    .profile { display: block; }
    .profile > .grid { margin-bottom: 16px; }
}

/* ============================================================== */
/*  Life-events timeline + attachments (added)                    */
/* ============================================================== */
.section-block { margin-top: 18px; }

.timeline-item { display: flex; gap: 14px; padding: 4px 0 14px; position: relative; }
.timeline-item:not(:last-child) .timeline-dot::after {
    content: ""; position: absolute; left: 5px; top: 16px; bottom: -6px; width: 2px; background: var(--line);
}
.timeline-dot { position: relative; flex: none; width: 12px; height: 12px; margin-top: 5px; border-radius: 50%; background: var(--gold); }
.timeline-body { flex: 1; }
.timeline-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.timeline-date { color: var(--ink-soft); font-weight: 600; font-size: 13px; }
.timeline-place { color: var(--muted); font-size: 13px; }
.timeline-notes { color: var(--ink-soft); margin: 6px 0 0; font-size: 14px; }

.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.attach { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.attach__thumb { display: block; aspect-ratio: 4 / 3; background: var(--surface); }
.attach__thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach__file { display: grid; place-items: center; height: 100%; font-weight: 700; color: var(--rose); letter-spacing: .04em; }
.attach__meta { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 12.5px; }
.attach__meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach__meta form { margin-left: auto; }

/* ============================================================== */
/*  Map · crop modal · share (added)                              */
/* ============================================================== */
.kin-map {
    height: 70vh; min-height: 420px;
    border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.leaflet-popup-content a { font-weight: 700; color: var(--green); }

.crop-modal {
    position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
    background: rgba(20,16,12,.66); padding: 20px;
}
.crop-modal[hidden] { display: none; }
.crop-modal__box {
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    width: min(560px, 94vw); padding: 16px; max-height: 90vh; display: flex; flex-direction: column;
}
.crop-modal__stage { background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.crop-modal__stage img { display: block; max-width: 100%; max-height: 60vh; }
.crop-modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.share-url { width: 100%; }
