*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:      #1D9E75; --green-dark: #0F6E56; --green-pale: #E1F5EE;
  --amber:      #EF9F27; --amber-pale: #FAEEDA; --coral: #D85A30;
  --text:       #1a1a1a; --text-2: #555; --text-3: #888;
  --border:     rgba(0,0,0,0.1); --border-2: rgba(0,0,0,0.18);
  --bg:         #f5f4f0; --bg-card: #fff; --bg-2: #f0efe9;
  --radius:     10px; --radius-lg: 14px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow:     0 2px 8px rgba(0,0,0,0.10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --text: #e8e6df; --text-2: #a8a49c; --text-3: #6e6b64;
    --border: rgba(255,255,255,0.1); --border-2: rgba(255,255,255,0.18);
    --bg: #1c1b18; --bg-card: #252420; --bg-2: #2a2925;
  }
}

body { font-family: 'Lora', Georgia, serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6; min-height: 100vh; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
.nav { background: var(--bg-card); border-bottom: 0.5px solid var(--border); padding: 0 1.5rem; display: flex; align-items: center; gap: 1rem; height: 56px; position: sticky; top: 0; z-index: 100; }
.nav-brand { font-family: 'Playfair Display', Georgia, serif; font-size: 17px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 7px; text-decoration: none; }
.nav-brand .leaf { color: var(--green); font-size: 20px; }
.nav-links { display: flex; gap: 4px; }
.nav-link { padding: 6px 12px; border-radius: var(--radius); font-size: 13px; cursor: pointer; border: none; background: transparent; color: var(--text-2); transition: background 0.15s; display: flex; align-items: center; gap: 5px; text-decoration: none; font-family: inherit; }
.nav-link:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--bg-2); color: var(--text); font-weight: 500; }
.nav-link .badge { background: var(--coral); color: white; border-radius: 99px; font-size: 10px; padding: 1px 5px; font-weight: 600; }
.nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.nav-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; border: 1.5px solid var(--green); }
.nav-user-name { font-size: 12px; font-weight: 500; }
.nav-role { font-size: 10px; padding: 1px 6px; border-radius: 99px; font-weight: 600; display: inline-block; }
.role-admin { background: #CECBF6; color: #3C3489; }
.role-moderator { background: var(--green-pale); color: var(--green-dark); }
.role-member { background: var(--bg-2); color: var(--text-2); }

/* Layout */
.page { max-width: 980px; margin: 0 auto; padding: 1.5rem 1.25rem; }

/* Cards */
.card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow-sm); }

/* Buttons */
.btn { padding: 8px 15px; border-radius: var(--radius); font-size: 13px; cursor: pointer; border: 0.5px solid var(--border-2); background: var(--bg-card); color: var(--text); display: inline-flex; align-items: center; gap: 6px; transition: background 0.15s; font-family: inherit; font-weight: 500; }
.btn:hover { background: var(--bg-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--green); color: white; border-color: var(--green); }
.btn-primary:hover { background: var(--green-dark); }
.btn-approve { background: #E1F5EE; color: #085041; border-color: #9FE1CB; }
.btn-decline { background: #FCEBEB; color: #791F1F; border-color: #F09595; }
.btn-danger  { background: #FCEBEB; color: #791F1F; border-color: #F09595; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 9px 11px; border-radius: var(--radius); border: 0.5px solid var(--border-2); background: var(--bg-card); color: var(--text); font-size: 14px; font-family: inherit; transition: border-color 0.15s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,158,117,0.12); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* Notices */
.notice { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; display: flex; gap: 8px; align-items: flex-start; margin-bottom: 1.25rem; }
.notice-info    { background: #E6F1FB; color: #185FA5; }
.notice-warning { background: var(--amber-pale); color: #854F0B; }
.notice-success { background: var(--green-pale); color: var(--green-dark); }
.notice-error   { background: #FCEBEB; color: #791F1F; }

/* Section headers */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-head h2 { font-family: 'Playfair Display', Georgia, serif; font-size: 20px; font-weight: 700; }

/* Tags */
.tag { font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.tag-admin     { background: #CECBF6; color: #3C3489; }
.tag-moderator { background: var(--green-pale); color: var(--green-dark); }
.tag-member    { background: var(--bg-2); color: var(--text-2); }
.tag-pending   { background: var(--amber-pale); color: #854F0B; }
.tag-active    { background: var(--green-pale); color: var(--green-dark); }
.tag-declined  { background: #FCEBEB; color: #791F1F; }
.tag-revoked   { background: #FCEBEB; color: #791F1F; }
.tag-pending_verification { background: var(--bg-2); color: var(--text-3); }

/* Avatar */
.avatar { border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Photo upload */
.photo-drop { border: 1.5px dashed var(--border-2); border-radius: var(--radius); padding: 20px; text-align: center; cursor: pointer; color: var(--text-3); font-size: 13px; transition: border-color 0.15s, background 0.15s; }
.photo-drop:hover { border-color: var(--green); background: var(--green-pale); }
.photo-drop i { font-size: 26px; display: block; margin-bottom: 6px; }
.photo-preview { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin: 0 auto 8px; display: block; border: 2px solid var(--green); }

/* Modal */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--bg-card); border-radius: var(--radius-lg); border: 0.5px solid var(--border); width: 480px; max-width: 100%; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-head { padding: 1.25rem 1.25rem 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-body { padding: 1rem 1.25rem 1.25rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 18px; padding: 2px; flex-shrink: 0; }
.modal-close:hover { color: var(--text); }
.info-row { display: flex; gap: 8px; align-items: flex-start; padding: 7px 0; border-bottom: 0.5px solid var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-2); width: 100px; flex-shrink: 0; display: flex; align-items: center; gap: 5px; }
.info-value { color: var(--text); flex: 1; line-height: 1.5; }

/* Empty / loader */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-3); font-size: 14px; }
.empty i { font-size: 40px; display: block; margin-bottom: 10px; opacity: 0.35; }
.loader { display: flex; align-items: center; justify-content: center; padding: 3rem; color: var(--text-3); font-size: 13px; gap: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; display: inline-block; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: 1.25rem; }
.stat-box { background: var(--bg-2); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat-num { font-size: 26px; font-weight: 700; font-family: 'Playfair Display',Georgia,serif; }
.stat-lbl { font-size: 11px; color: var(--text-2); margin-top: 2px; }

/* User rows */
.user-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 0.5px solid var(--border); }
.user-row:last-child { border-bottom: none; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; }
.user-meta { font-size: 11px; color: var(--text-3); }

/* Login page */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 1.5rem; }
.login-box { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; width: 420px; max-width: 100%; box-shadow: var(--shadow); }
.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo .tree-icon { font-size: 44px; color: var(--green); }
.login-logo h1 { font-family: 'Playfair Display',Georgia,serif; font-size: 22px; margin-top: 8px; font-weight: 700; }
.login-logo p { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.divider { text-align: center; color: var(--text-3); font-size: 12px; margin: 1rem 0; position: relative; }
.divider::before, .divider::after { content:''; position:absolute; top:50%; width:42%; height:0.5px; background:var(--border); }
.divider::before { left:0; } .divider::after { right:0; }

/* Tree */
.tree-canvas { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 2rem 1.5rem; overflow-x: auto; }
.gen-label { text-align:center; font-size:11px; color:var(--text-3); letter-spacing:.08em; margin-bottom:12px; font-weight:600; }
.gen-row { display:flex; justify-content:center; align-items:flex-start; gap:10px; flex-wrap:wrap; }
.gen-spacer { height:44px; display:flex; justify-content:center; }
.v-line { width:1px; background:var(--border-2); }
.couple-wrap { display:flex; align-items:center; gap:4px; }
.couple-line { width:28px; height:2px; background:var(--border-2); flex-shrink:0; }
.member-node { width:90px; text-align:center; cursor:pointer; flex-shrink:0; }
.member-node-av { width:56px; height:56px; border-radius:50%; border:2px solid var(--border); background:var(--bg-2); margin:0 auto 6px; transition:border-color 0.15s,transform 0.15s; display:flex; align-items:center; justify-content:center; font-size:16px; font-weight:600; overflow:hidden; }
.member-node:hover .member-node-av { border-color:var(--green); transform:scale(1.06); }
.member-node-av img { width:100%; height:100%; object-fit:cover; }
.member-node-name { font-size:11px; font-weight:600; line-height:1.3; }
.member-node-years { font-size:10px; color:var(--text-3); margin-top:1px; }
.member-node.is-pending .member-node-av { border-color:var(--amber); border-style:dashed; }
.member-node.is-me .member-node-av { border-color:var(--green); border-width:2.5px; }
.pending-pill { font-size:10px; color:#BA7517; background:var(--amber-pale); padding:1px 6px; border-radius:99px; display:inline-block; margin-top:3px; }
.tree-legend { display:flex; gap:1.5rem; justify-content:center; margin-top:1.5rem; padding-top:1rem; border-top:0.5px solid var(--border); flex-wrap:wrap; }
.legend-item { display:flex; align-items:center; gap:6px; font-size:11px; color:var(--text-2); }

/* FAB */
.fab { position:fixed; bottom:2rem; right:2rem; width:52px; height:52px; border-radius:50%; background:var(--green); color:white; border:none; font-size:26px; cursor:pointer; display:flex; align-items:center; justify-content:center; box-shadow:0 4px 16px rgba(29,158,117,0.35); transition:background 0.15s,transform 0.15s; z-index:200; }
.fab:hover { background:var(--green-dark); transform:scale(1.08); }

/* Slide panel */
.slide-panel { position:fixed; inset:0; z-index:400; display:flex; align-items:flex-end; justify-content:center; }
.slide-backdrop { position:absolute; inset:0; background:rgba(0,0,0,0.4); }
.slide-box { position:relative; background:var(--bg-card); border-radius:var(--radius-lg) var(--radius-lg) 0 0; width:100%; max-width:580px; max-height:90vh; overflow-y:auto; padding:1.5rem; animation:slideUp 0.25s ease; }
@keyframes slideUp { from{transform:translateY(100%)} to{transform:translateY(0)} }
.slide-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:1.25rem; }
.slide-head h3 { font-family:'Playfair Display',Georgia,serif; font-size:17px; font-weight:700; display:flex; align-items:center; gap:8px; }

/* Messages */
.msg-wrap { display:flex; height:calc(100vh - 56px); overflow:hidden; }
.msg-sidebar { width:260px; flex-shrink:0; border-right:0.5px solid var(--border); overflow-y:auto; background:var(--bg-card); }
.msg-sidebar-head { padding:1rem; border-bottom:0.5px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.msg-sidebar-head h3 { font-size:14px; font-weight:600; }
.conv-item { padding:12px 1rem; border-bottom:0.5px solid var(--border); cursor:pointer; transition:background 0.15s; }
.conv-item:hover { background:var(--bg-2); }
.conv-item.active { background:var(--green-pale); }
.conv-name { font-size:13px; font-weight:600; }
.conv-preview { font-size:11px; color:var(--text-3); margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.conv-unread { background:var(--green); color:white; border-radius:99px; font-size:10px; padding:1px 6px; font-weight:600; }
.msg-main { flex:1; display:flex; flex-direction:column; overflow:hidden; }
.msg-header { padding:1rem 1.25rem; border-bottom:0.5px solid var(--border); background:var(--bg-card); font-size:14px; font-weight:600; display:flex; align-items:center; gap:8px; }
.msg-body { flex:1; overflow-y:auto; padding:1rem 1.25rem; display:flex; flex-direction:column; gap:8px; }
.msg-bubble { max-width:70%; padding:8px 12px; border-radius:12px; font-size:13px; line-height:1.5; }
.msg-bubble.mine { background:var(--green); color:white; align-self:flex-end; border-bottom-right-radius:3px; }
.msg-bubble.theirs { background:var(--bg-2); color:var(--text); align-self:flex-start; border-bottom-left-radius:3px; }
.msg-time { font-size:10px; opacity:0.6; margin-top:3px; }
.msg-input-wrap { padding:1rem 1.25rem; border-top:0.5px solid var(--border); background:var(--bg-card); display:flex; gap:8px; }
.msg-input-wrap input { flex:1; }
.msg-empty { display:flex; align-items:center; justify-content:center; flex:1; color:var(--text-3); font-size:14px; flex-direction:column; gap:8px; }
.msg-empty i { font-size:40px; opacity:0.3; }

/* Profile page */
.profile-hero { display:flex; gap:1.5rem; align-items:flex-start; margin-bottom:1.5rem; flex-wrap:wrap; }
.profile-av-lg { width:96px; height:96px; font-size:32px; flex-shrink:0; }
.profile-details { flex:1; min-width:200px; }
.profile-name { font-family:'Playfair Display',Georgia,serif; font-size:24px; font-weight:700; }
.profile-sub { font-size:13px; color:var(--text-2); margin-top:4px; }
.profile-section { margin-top:1.25rem; padding-top:1.25rem; border-top:0.5px solid var(--border); }
.profile-section h4 { font-size:13px; font-weight:600; color:var(--text-2); margin-bottom:8px; text-transform:uppercase; letter-spacing:.06em; }
