/* ============================================================
   ZANZIBAR FAMILY TREE — MAIN STYLESHEET
   Mobile-first design
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Tajawal:wght@300;400;500;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --gold:        #C9902A;
    --gold-light:  #F0C060;
    --gold-pale:   #FDF3DC;
    --brown-deep:  #3B1F0A;
    --brown-mid:   #6B3A1F;
    --ocean:       #1A4A6B;
    --ocean-light: #2E7DAA;
    --cream:       #FAF3E0;
    --sand:        #EDD9A3;
    --green-isle:  #2D6A4F;
    --text-dark:   #1C0F05;
    --text-mid:    #4A2C0A;
    --red-dead:    #8B1A1A;
    --green-alive: #1B5E20;
}

html, body {
    width: 100%; min-height: 100vh;
    font-family: 'Tajawal', sans-serif;
    color: var(--text-dark);
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { font-family: 'Tajawal', sans-serif; cursor: pointer; }

/* ============================================================
   PAGE: DEVICE (index.php)
   ============================================================ */
.page-device {
    min-height: 100vh;
    background: linear-gradient(160deg, var(--brown-deep) 0%, var(--ocean) 65%, #0A1628 100%);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 24px 18px;
    position: relative; overflow: hidden;
}

.stars-bg {
    position: absolute; inset: 0; pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 20% 15%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 75% 25%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 40% 60%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 85% 70%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 10% 80%, rgba(255,255,255,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 60% 90%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(2px 2px at 30% 40%, rgba(201,144,42,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 90% 10%, rgba(255,255,255,0.7) 0%, transparent 100%);
}

.device-card {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(201,144,42,0.35);
    border-radius: 22px;
    padding: 28px 22px;
    width: 100%; max-width: 390px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 8px 48px rgba(0,0,0,0.6);
    position: relative; z-index: 1;
}

.device-logo { text-align: center; margin-bottom: 26px; }
.dhow-icon {
    font-size: 52px; display: block; margin-bottom: 10px;
    filter: drop-shadow(0 3px 10px rgba(201,144,42,0.6));
    animation: bobFloat 3s ease-in-out infinite;
}
@keyframes bobFloat {
    0%,100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}
.arabic-title {
    font-family: 'Amiri', serif;
    font-size: 28px; color: var(--gold-light);
    line-height: 1.3; display: block;
}
.sub-title {
    font-size: 12px; color: rgba(255,255,255,0.55);
    margin-top: 3px; display: block;
    letter-spacing: 2.5px; text-transform: uppercase;
}
.island-names {
    font-size: 11px; color: var(--gold);
    display: block; margin-top: 4px;
    letter-spacing: 1.5px;
}

.id-label, .token-label {
    font-size: 11px; color: rgba(255,255,255,0.5);
    letter-spacing: 2px; text-transform: uppercase;
    margin-bottom: 8px; display: block;
}
.id-box {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(201,144,42,0.3);
    border-radius: 11px; padding: 13px 14px;
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 6px;
}
.id-value {
    flex: 1; font-family: monospace;
    font-size: 12px; color: var(--gold-light);
    word-break: break-all; line-height: 1.5;
}
.copy-btn {
    background: var(--gold); border: none;
    border-radius: 8px; padding: 8px 14px;
    color: white; font-size: 13px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    transition: all 0.2s; flex-shrink: 0;
}
.copy-btn:active { transform: scale(0.95); }
.copy-hint {
    font-size: 11px; color: rgba(255,255,255,0.38);
    text-align: center; margin-bottom: 22px;
    line-height: 1.5;
}
.divider {
    border: none; border-top: 1px solid rgba(201,144,42,0.18);
    margin: 18px 0;
}
.token-input {
    width: 100%; background: rgba(0,0,0,0.3);
    border: 1.5px solid rgba(201,144,42,0.3);
    border-radius: 11px; padding: 13px 15px;
    color: white; font-size: 15px;
    font-family: monospace; outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}
.token-input:focus { border-color: var(--gold); }
.token-input::placeholder { color: rgba(255,255,255,0.22); font-size: 13px; font-family: 'Tajawal', sans-serif; }

.enter-btn {
    width: 100%; margin-top: 14px;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    border: none; border-radius: 13px;
    padding: 16px; color: var(--brown-deep);
    font-size: 16px; font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 22px rgba(201,144,42,0.4);
    transition: all 0.2s;
}
.enter-btn:active { transform: scale(0.98); opacity: 0.9; }
.error-msg {
    color: #FF7070; font-size: 13px;
    text-align: center; margin-top: 10px;
    line-height: 1.4;
}

/* ============================================================
   PAGE: MAP (map.php)
   ============================================================ */
.page-map {
    min-height: 100vh;
    background: linear-gradient(180deg, #080F1C 0%, #0D2240 50%, #0A1628 100%);
    display: flex; flex-direction: column;
    align-items: center; padding-bottom: 30px;
}
.map-header {
    width: 100%; padding: 18px 18px 10px;
    text-align: center;
}
.map-title {
    font-family: 'Amiri', serif;
    font-size: 20px; color: var(--gold-light);
}
.map-subtitle {
    font-size: 10px; color: rgba(255,255,255,0.4);
    letter-spacing: 2.5px; margin-top: 4px;
}
.map-canvas-wrap {
    width: 100%; max-width: 420px;
}
.map-svg {
    width: 100%; display: block;
}

/* Route animation */
#routeLine1 {
    animation: dashScroll1 2.5s linear infinite;
}
#routeLine2 {
    animation: dashScroll2 2s linear infinite 1s;
}
@keyframes dashScroll1 {
    to { stroke-dashoffset: -200; }
}
@keyframes dashScroll2 {
    to { stroke-dashoffset: -150; }
}

/* Pulse rings */
.pulse-ring { animation: pulseRing 2s ease-out infinite; }
@keyframes pulseRing {
    0%  { opacity: 0.3; r: 10; }
    50% { opacity: 0.1; r: 18; }
    100%{ opacity: 0; r: 24; }
}
.island-glow { animation: islandGlow 2s ease-in-out infinite; }
@keyframes islandGlow {
    0%,100% { opacity: 0.9; }
    50%      { opacity: 0.5; }
}

/* Dhow animation */
#dhow { transition: transform 0.5s ease; }

.map-narration {
    width: 100%; max-width: 420px;
    padding: 16px 18px;
    background: rgba(201,144,42,0.07);
    border-top: 1px solid rgba(201,144,42,0.18);
    border-bottom: 1px solid rgba(201,144,42,0.18);
}
.narration-text {
    font-family: 'Amiri', serif;
    font-size: 15px; color: rgba(255,255,255,0.85);
    line-height: 1.9; text-align: center; min-height: 100px;
}
.cursor {
    display: inline-block; width: 2px; height: 16px;
    background: var(--gold); margin-left: 2px;
    animation: blink 0.7s step-end infinite;
    vertical-align: middle;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

.map-bottom {
    padding: 18px; width: 100%; max-width: 420px;
    display: flex; flex-direction: column; gap: 14px;
}
.persons-intro { display: flex; gap: 12px; }
.person-card {
    flex: 1; background: rgba(255,255,255,0.06);
    border: 1px solid rgba(201,144,42,0.28);
    border-radius: 14px; padding: 14px 10px;
    text-align: center; display: flex;
    flex-direction: column; gap: 3px;
}
.person-card-2 { border-color: rgba(46,125,170,0.35); }
.person-num {
    font-family: 'Amiri', serif;
    font-size: 30px; color: var(--gold-light);
}
.person-island {
    font-size: 10px; color: rgba(255,255,255,0.6);
    letter-spacing: 1px;
}
.person-name {
    font-family: 'Amiri', serif;
    font-size: 14px; color: white;
}
.person-desc { font-size: 10px; color: rgba(255,255,255,0.4); }

.start-tree-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    border: none; border-radius: 14px;
    padding: 18px 20px; color: var(--brown-deep);
    font-size: 17px; font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 6px 26px rgba(201,144,42,0.45);
    transition: all 0.2s;
    animation: fadeInUp 0.5s ease forwards;
}
.start-tree-btn:active { transform: scale(0.98); }
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PAGE: TREE (tree.php)
   ============================================================ */
.page-tree {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--cream) 0%, #FFF8EC 100%);
    padding-bottom: 40px;
}

/* Header */
.tree-header {
    background: linear-gradient(135deg, var(--brown-deep) 0%, #5A2A0A 100%);
    padding: 14px 14px 16px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 4px 20px rgba(0,0,0,0.35);
}
.tree-header-top {
    display: flex; align-items: center;
    gap: 10px; margin-bottom: 8px;
}
.back-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(201,144,42,0.3);
    border-radius: 8px; padding: 7px 13px;
    color: var(--gold-light); font-size: 17px;
    cursor: pointer; transition: all 0.2s;
    flex-shrink: 0; font-weight: 700;
}
.back-btn:active { background: rgba(201,144,42,0.25); }
.tree-header-info { flex: 1; min-width: 0; }
.tree-person-num {
    font-family: 'Amiri', serif;
    font-size: 30px; color: var(--gold-light); line-height: 1;
}
.tree-person-name {
    font-family: 'Amiri', serif;
    font-size: 17px; color: white; margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tree-caption {
    font-size: 12px; color: rgba(255,255,255,0.62);
    background: rgba(0,0,0,0.2); border-radius: 8px;
    padding: 7px 11px; line-height: 1.5;
}
.tree-caption strong { color: var(--gold-light); }

/* Breadcrumb */
.breadcrumb {
    display: flex; align-items: center;
    gap: 5px; flex-wrap: wrap;
    padding: 9px 14px;
    background: rgba(59,31,10,0.06);
    border-bottom: 1px solid rgba(201,144,42,0.12);
    font-size: 11px;
}
.bc-item { color: var(--ocean-light); font-weight: 600; cursor: pointer; }
.bc-sep  { color: var(--gold); opacity: 0.6; }
.bc-current { color: var(--brown-deep); font-weight: 700; }

/* Add section */
.add-section {
    margin: 14px; padding: 16px;
    background: white; border-radius: 16px;
    border: 1px solid rgba(201,144,42,0.18);
    box-shadow: 0 2px 14px rgba(0,0,0,0.07);
}
.add-section-title {
    font-family: 'Amiri', serif;
    font-size: 16px; color: var(--brown-deep);
    margin-bottom: 14px;
    display: flex; align-items: center; gap: 8px;
}
.add-section-title::before {
    content: '+'; font-size: 14px; font-family: monospace;
    background: var(--gold); color: white;
    width: 24px; height: 24px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
}
.form-group { margin-bottom: 10px; }
.form-label {
    font-size: 11px; color: var(--brown-mid);
    font-weight: 600; margin-bottom: 5px;
    display: block; letter-spacing: 0.5px;
    text-transform: uppercase;
}
.form-input {
    width: 100%; border: 1.5px solid #E0D0B0;
    border-radius: 10px; padding: 11px 13px;
    font-size: 15px; font-family: 'Tajawal', sans-serif;
    color: var(--text-dark); background: var(--cream);
    outline: none; transition: border-color 0.2s;
    -webkit-appearance: none;
}
.form-input:focus { border-color: var(--gold); }

.status-row { display: flex; gap: 8px; }
.status-option {
    flex: 1; padding: 10px 6px;
    border-radius: 10px; border: 1.5px solid #E0D0B0;
    text-align: center; cursor: pointer;
    transition: all 0.2s; font-size: 13px;
    background: var(--cream); user-select: none;
}
.status-option.selected.alive-sel {
    border-color: var(--green-alive);
    background: #E8F5E9; color: var(--green-alive);
}
.status-option.selected.dead-sel {
    border-color: var(--red-dead);
    background: #FFEBEE; color: var(--red-dead);
}
.next-num-preview {
    font-size: 12px; color: var(--ocean-light);
    background: rgba(46,125,170,0.08);
    border-radius: 8px; padding: 8px 12px;
    margin-top: 4px; margin-bottom: 4px;
}
.save-btn {
    width: 100%; margin-top: 6px;
    background: linear-gradient(135deg, var(--gold), var(--brown-mid));
    border: none; border-radius: 12px;
    padding: 14px; color: white;
    font-size: 15px; font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 3px 14px rgba(107,58,31,0.3);
    transition: all 0.2s;
}
.save-btn:active  { transform: scale(0.98); }
.save-btn:disabled { opacity: 0.6; }
.form-msg { font-size: 13px; text-align: center; margin-top: 8px; color: var(--green-alive); }

/* Children section */
.children-section { margin: 0 14px 30px; }
.section-heading {
    font-family: 'Amiri', serif;
    font-size: 16px; color: var(--brown-deep);
    margin-bottom: 12px; padding-bottom: 8px;
    border-bottom: 2px solid var(--gold);
    display: flex; align-items: center; gap: 8px;
}
.child-count {
    background: var(--gold); color: white;
    font-family: 'Tajawal', sans-serif;
    font-size: 12px; font-weight: 700;
    padding: 2px 9px; border-radius: 10px;
}

/* Child card */
.child-card {
    background: white;
    border: 1px solid rgba(201,144,42,0.16);
    border-radius: 15px; margin-bottom: 13px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    animation: cardIn 0.3s ease;
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
.child-card-top {
    display: flex; align-items: center;
    gap: 12px; padding: 13px;
}
.child-avatar {
    width: 54px; height: 54px; border-radius: 50%;
    border: 2px solid var(--sand);
    flex-shrink: 0; background: var(--sand);
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; overflow: hidden; position: relative;
    cursor: pointer;
}
.child-avatar img {
    width: 100%; height: 100%; object-fit: cover;
    border-radius: 50%;
}
.avatar-upload-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s; border-radius: 50%;
    font-size: 18px;
}
.child-avatar:active .avatar-upload-overlay { opacity: 1; }

.child-info { flex: 1; min-width: 0; }
.child-num {
    font-size: 11px; color: var(--gold);
    font-weight: 700; letter-spacing: 1px;
}
.child-name {
    font-family: 'Amiri', serif;
    font-size: 17px; color: var(--text-dark);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; padding: 3px 8px;
    border-radius: 10px; margin-top: 3px;
    font-weight: 600;
}
.status-badge.alive { background: #E8F5E9; color: var(--green-alive); }
.status-badge.dead  { background: #FFEBEE; color: var(--red-dead); }
.grandchild-hint {
    font-size: 11px; color: var(--ocean-light);
    margin-top: 3px;
}

/* Alive / Dua boxes */
.alive-box {
    background: linear-gradient(135deg, #071207, #0F2410);
    padding: 10px 14px; border-top: 1px solid rgba(45,106,79,0.3);
    text-align: center;
}
.alive-arabic {
    font-family: 'Amiri', serif; font-size: 14px;
    color: #81C784; line-height: 2;
    direction: rtl;
}
.alive-trans { font-size: 10px; color: rgba(255,255,255,0.4); margin-top: 2px; }

.dua-box {
    background: linear-gradient(135deg, #120707, #240F0F);
    padding: 10px 14px; border-top: 1px solid rgba(201,144,42,0.2);
    text-align: center;
}
.dua-arabic {
    font-family: 'Amiri', serif; font-size: 14px;
    color: var(--gold-light); line-height: 2;
    direction: rtl;
}
.dua-trans { font-size: 10px; color: rgba(255,255,255,0.4); margin-top: 2px; }

.status-img {
    width: 100%; max-height: 90px;
    object-fit: contain;
}

/* Action buttons */
.child-card-actions {
    display: flex; border-top: 1px solid rgba(201,144,42,0.1);
}
.action-btn {
    flex: 1; padding: 11px 5px;
    background: none; border: none;
    font-family: 'Tajawal', sans-serif;
    font-size: 12px; cursor: pointer;
    color: var(--brown-mid); font-weight: 500;
    transition: background 0.2s;
    display: flex; align-items: center;
    justify-content: center; gap: 4px;
    text-decoration: none;
}
.action-btn:not(:last-child) {
    border-right: 1px solid rgba(201,144,42,0.1);
}
.action-btn:active  { background: rgba(201,144,42,0.08); }
.action-btn.primary { color: var(--ocean-light); font-weight: 700; }
.action-btn.view-photo { color: var(--green-isle); }
.action-btn.edit-btn   { color: var(--gold); }

/* Edit panel */
.edit-panel {
    padding: 12px 13px;
    border-top: 1px solid rgba(201,144,42,0.1);
    background: rgba(201,144,42,0.04);
}
.edit-row { margin-bottom: 8px; }

/* Empty state */
.empty-children {
    text-align: center; padding: 36px 20px;
    color: rgba(107,58,31,0.45);
    font-family: 'Amiri', serif; font-size: 16px;
}
.empty-icon { font-size: 42px; display: block; margin-bottom: 10px; }

/* ============================================================
   PHOTO MODAL
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0; z-index: 999;
    background: rgba(0,0,0,0.88);
    display: flex; align-items: center; justify-content: center;
    padding: 20px; animation: fadeIn 0.2s;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.modal-box {
    background: white; border-radius: 20px;
    width: 100%; max-width: 380px;
    padding: 20px; position: relative;
    animation: slideUp 0.25s;
    max-height: 90vh; overflow-y: auto;
}
@keyframes slideUp {
    from{transform:translateY(28px);opacity:0}
    to  {transform:translateY(0);opacity:1}
}
.modal-close {
    position: absolute; top: 12px; right: 12px;
    background: rgba(0,0,0,0.08); border: none;
    border-radius: 50%; width: 30px; height: 30px;
    font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.modal-member-name {
    font-family: 'Amiri', serif;
    font-size: 18px; color: var(--brown-deep);
    margin-bottom: 14px; margin-right: 36px;
}
.modal-photo-large {
    width: 100%; aspect-ratio: 1;
    object-fit: cover; border-radius: 14px;
    border: 2px solid var(--sand);
}
.modal-photo-placeholder {
    width: 100%; aspect-ratio: 1;
    background: var(--cream); border-radius: 14px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 8px;
    border: 2px dashed var(--sand);
}
.modal-photo-placeholder span { font-size: 52px; }
.modal-photo-placeholder p { font-size: 13px; color: var(--brown-mid); }

.upload-photo-btn {
    width: 100%; margin-top: 13px;
    background: var(--gold); border: none;
    border-radius: 11px; padding: 13px;
    color: white; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
    display: block; text-align: center;
}
.upload-photo-btn:active { transform: scale(0.98); }

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */
.toast {
    position: fixed; bottom: 28px; left: 50%;
    transform: translateX(-50%);
    background: var(--brown-deep); color: var(--gold-light);
    padding: 10px 20px; border-radius: 22px;
    font-size: 13px; z-index: 9999;
    border: 1px solid var(--gold);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    white-space: nowrap;
    animation: toastIn 0.3s ease;
    pointer-events: none;
}
@keyframes toastIn {
    from{opacity:0;transform:translateX(-50%) translateY(10px)}
    to  {opacity:1;transform:translateX(-50%) translateY(0)}
}

/* ============================================================
   ADDITIONS v2 — Admin button, Mother, View/Edit mode
   ============================================================ */

/* Admin toggle button on login page */
.admin-toggle-btn {
    width: 100%; margin-top: 14px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(201,144,42,0.25);
    border-radius: 12px; padding: 12px;
    color: rgba(255,255,255,0.55);
    font-size: 13px; cursor: pointer;
    font-family: 'Tajawal', sans-serif;
    transition: all 0.2s; letter-spacing: 0.5px;
}
.admin-toggle-btn:active { background: rgba(201,144,42,0.12); color: var(--gold-light); }

/* 2FA / TOTP card styling */
.qr-setup-box { text-align: center; margin-bottom: 16px; }
.qr-instruction {
    font-size: 13px; color: rgba(255,255,255,0.7);
    line-height: 1.6; margin-bottom: 14px;
}
.qr-image {
    border-radius: 12px; border: 3px solid var(--gold);
    display: block; margin: 0 auto 12px;
    width: 180px; height: 180px;
}
.secret-display {
    font-size: 11px; color: rgba(255,255,255,0.4);
    margin-top: 8px;
}
.secret-display code {
    color: var(--gold-light); font-size: 12px;
    background: rgba(0,0,0,0.3); padding: 2px 6px;
    border-radius: 4px; letter-spacing: 1px;
}
.totp-instruction {
    text-align: center; padding: 16px 8px;
    color: rgba(255,255,255,0.7); font-size: 13px;
    line-height: 1.6; margin-bottom: 12px;
}
.totp-input {
    text-align: center; font-size: 28px;
    letter-spacing: 10px; font-weight: 700;
}
.totp-input-modal {
    text-align: center; font-size: 28px;
    letter-spacing: 10px; font-weight: 700;
    width: 100%; background: rgba(0,0,0,0.06);
    border: 1.5px solid #E0D0B0; border-radius: 11px;
    padding: 13px 15px; outline: none;
    font-family: monospace; color: var(--text-dark);
    transition: border-color 0.2s;
}
.totp-input-modal:focus { border-color: var(--gold); }

/* ── VIEW / EDIT MODE TOGGLE ── */
.mode-toggle {
    display: flex; gap: 3px;
    background: rgba(0,0,0,0.2);
    border-radius: 10px; padding: 3px;
    flex-shrink: 0;
}
.mode-btn {
    padding: 6px 10px; border-radius: 7px;
    border: none; font-size: 12px;
    font-family: 'Tajawal', sans-serif;
    cursor: pointer; font-weight: 600;
    background: transparent; color: rgba(255,255,255,0.5);
    transition: all 0.2s; white-space: nowrap;
}
.mode-btn.active {
    background: var(--gold); color: white;
    box-shadow: 0 2px 8px rgba(201,144,42,0.4);
}

/* Hidden in view mode */
.edit-only.hidden, .hidden { display: none !important; }

/* ── MOTHER ROW IN CARD ── */
.mother-row {
    display: flex; align-items: center;
    gap: 8px; padding: 9px 13px;
    background: rgba(201,144,42,0.05);
    border-top: 1px solid rgba(201,144,42,0.1);
    flex-wrap: wrap;
}
.mother-label {
    font-size: 11px; font-weight: 700;
    color: var(--brown-mid); white-space: nowrap;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.mother-value {
    font-family: 'Amiri', serif; font-size: 14px;
    color: var(--text-dark); flex: 1;
}
.mother-link {
    font-size: 11px; color: var(--ocean-light);
    font-weight: 700; text-decoration: none;
    background: rgba(46,125,170,0.1);
    padding: 2px 8px; border-radius: 8px;
    white-space: nowrap;
}
.mother-link:active { background: rgba(46,125,170,0.2); }

/* ── MOTHER RADIO OPTIONS (form) ── */
.mother-radio-group {
    display: flex; flex-direction: column; gap: 8px;
}
.mother-option {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 13px; border-radius: 11px;
    border: 1.5px solid #E0D0B0;
    background: var(--cream); cursor: pointer;
    transition: all 0.2s; user-select: none;
}
.mother-option.selected {
    border-color: var(--gold);
    background: rgba(201,144,42,0.07);
}
.mopt-icon { font-size: 22px; flex-shrink: 0; }
.mopt-text { display: flex; flex-direction: column; gap: 1px; }
.mopt-text strong { font-size: 13px; color: var(--text-dark); }
.mopt-text small  { font-size: 11px; color: var(--brown-mid); }

/* Dropdown for family mother */
select.form-input {
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B3A1F' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* ============================================================
   v2.1 — Compact pills + Mother radio fix
   ============================================================ */

/* 2-column layout for Gender + Status */
.form-2col {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 10px; margin-bottom: 10px;
}

/* Compact pill radio buttons */
.pill-row {
    display: flex; flex-direction: column; gap: 5px;
}
.pill {
    display: flex; align-items: center; justify-content: center;
    gap: 4px; padding: 8px 6px;
    border-radius: 9px; border: 1.5px solid #E0D0B0;
    background: var(--cream); cursor: pointer;
    font-size: 12px; font-weight: 600;
    transition: all 0.18s; user-select: none;
    text-align: center; line-height: 1.2;
}
.pill input[type=radio] { display: none; }
.pill.selected { border-color: var(--gold); background: rgba(201,144,42,0.1); color: var(--brown-deep); }
.pill-alive.selected { border-color: var(--green-alive); background: #E8F5E9; color: var(--green-alive); }
.pill-dead.selected  { border-color: var(--red-dead);    background: #FFEBEE; color: var(--red-dead); }

/* ── Mother options — proper card style ── */
.mother-opts {
    display: flex; flex-direction: column; gap: 7px;
}
.mopt {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px; border-radius: 11px;
    border: 1.5px solid #E0D0B0;
    background: var(--cream); cursor: pointer;
    transition: all 0.18s; user-select: none;
    position: relative;
}
.mopt input[type=radio] { display: none; }

/* Custom radio dot */
.mopt-dot {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid #CCC; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.18s;
}
.mopt-dot::after {
    content: ''; width: 8px; height: 8px;
    border-radius: 50%; background: transparent;
    transition: all 0.18s;
}
.mopt-sel .mopt-dot {
    border-color: var(--gold);
}
.mopt-sel .mopt-dot::after {
    background: var(--gold);
}
.mopt-sel {
    border-color: var(--gold);
    background: rgba(201,144,42,0.07);
}

.mopt-body {
    display: flex; flex-direction: column; gap: 1px;
}
.mopt-body strong { font-size: 13px; color: var(--text-dark); }
.mopt-body small  { font-size: 11px; color: var(--brown-mid); }

/* Mother value in card */
.mother-in-family {
    color: var(--ocean-light); font-weight: 700;
    font-family: 'Amiri', serif;
}
.mother-unknown {
    color: rgba(0,0,0,0.35); font-style: italic;
    font-size: 13px;
}

/* ============================================================
   ROOT PERSON HEADER — big shiny display
   ============================================================ */
.tree-header-root {
    background: linear-gradient(135deg, #1C0A02 0%, var(--brown-deep) 40%, #5A2A0A 100%);
    padding-bottom: 20px;
}
.tree-header-root .tree-header-top {
    align-items: flex-start;
    padding-top: 4px;
}

/* Namba kubwa ya mzazi mkubwa */
.root-number {
    font-family: 'Amiri', serif;
    font-size: 72px;
    line-height: 0.85;
    color: var(--gold-light);
    text-shadow:
        0 0 30px rgba(201,144,42,0.8),
        0 0 60px rgba(201,144,42,0.4),
        0 2px 4px rgba(0,0,0,0.5);
    letter-spacing: -2px;
}

/* Jina kubwa la mzazi mkubwa */
.root-name {
    font-family: 'Amiri', serif;
    font-size: 22px;
    color: white;
    line-height: 1.3;
    margin-top: 4px;
    text-shadow: 0 1px 8px rgba(0,0,0,0.5);
    /* Allow wrapping on small screens */
    word-break: break-word;
}

/* Shimmer animation on number */
@keyframes goldShimmer {
    0%   { text-shadow: 0 0 20px rgba(201,144,42,0.6), 0 0 40px rgba(201,144,42,0.3); }
    50%  { text-shadow: 0 0 40px rgba(240,192,96,1),   0 0 80px rgba(201,144,42,0.6); }
    100% { text-shadow: 0 0 20px rgba(201,144,42,0.6), 0 0 40px rgba(201,144,42,0.3); }
}
.root-number {
    animation: goldShimmer 3s ease-in-out infinite;
}
/* ================================================================
   ONGEZA MISTARI HIII CHINI KABISA YA style.css YAKO
   (baada ya mstari wa mwisho wote uliopo)
================================================================ */

/* ROOT PERSON — namba kubwa inayong'aa */
.tree-header-root {
    background: linear-gradient(135deg, #1C0A02 0%, #3B1F0A 50%, #5A2A0A 100%) !important;
}
.root-number {
    font-family: 'Amiri', serif;
    font-size: 64px;
    line-height: 0.9;
    color: #F0C060;
    display: block;
    text-shadow: 0 0 30px rgba(201,144,42,0.9), 0 2px 4px rgba(0,0,0,0.6);
    animation: goldShimmer 3s ease-in-out infinite;
}
.root-name {
    font-family: 'Amiri', serif;
    font-size: 20px;
    color: #ffffff;
    display: block;
    margin-top: 2px;
    line-height: 1.3;
    text-shadow: 0 1px 6px rgba(0,0,0,0.5);
}
@keyframes goldShimmer {
    0%,100% { text-shadow: 0 0 20px rgba(201,144,42,0.7), 0 0 40px rgba(201,144,42,0.3); }
    50%      { text-shadow: 0 0 50px rgba(240,192,96,1),   0 0 90px rgba(201,144,42,0.7); }
}

/* 2-column layout for Gender + Status */
.form-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}
.pill-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.pill {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 6px;
    border-radius: 9px;
    border: 1.5px solid #E0D0B0;
    background: #FAF3E0;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.18s;
    user-select: none;
    text-align: center;
}
.pill input[type=radio] { display: none; }
.pill.selected       { border-color: #C9902A; background: rgba(201,144,42,0.1); color: #3B1F0A; }
.pill-alive.selected { border-color: #1B5E20; background: #E8F5E9; color: #1B5E20; }
.pill-dead.selected  { border-color: #8B1A1A; background: #FFEBEE; color: #8B1A1A; }

/* Mother options — card style */
.mother-opts {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 6px;
}
.mopt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: 11px;
    border: 1.5px solid #E0D0B0;
    background: #FAF3E0;
    cursor: pointer;
    transition: all 0.18s;
    user-select: none;
}
.mopt input[type=radio] { display: none; }
.mopt-dot {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 50%;
    border: 2px solid #CCC;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s;
    position: relative;
}
.mopt-dot::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: transparent;
    transition: all 0.18s;
}
.mopt-sel .mopt-dot        { border-color: #C9902A; }
.mopt-sel .mopt-dot::after { background: #C9902A; }
.mopt-sel {
    border-color: #C9902A;
    background: rgba(201,144,42,0.07);
}
.mopt-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.mopt-body strong { font-size: 13px; color: #1C0F05; }
.mopt-body small  { font-size: 11px; color: #4A2C0A; }

/* Mother display in card */
.mother-in-family {
    color: #2E7DAA;
    font-weight: 700;
    font-family: 'Amiri', serif;
}
.mother-unknown {
    color: rgba(0,0,0,0.35);
    font-style: italic;
    font-size: 13px;
}