:root {
  --primary: #1f4d3a;
  --primary-dark: #143628;
  --primary-soft: #e3eee8;
  --accent: #c9a227;
  --accent-soft: #f6ecc8;
  --bg: #f6f3ea;
  --surface: #ffffff;
  --surface-2: #faf8f2;
  --text: #1d2621;
  --muted: #66716b;
  --border: #e4ded0;
  --danger: #b42318;
  --danger-soft: #fde7e4;
  --success: #1a7f4b;
  --success-soft: #e2f4ea;
  --warning: #8a6100;
  --warning-soft: #fdf1cf;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 24px rgba(20, 54, 40, .08);
  --shadow-lg: 0 18px 50px rgba(20, 54, 40, .16);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --primary-soft: #1f3a2d;
  --accent-soft: #3d331a;
  --bg: #0f1612;
  --surface: #17211b;
  --surface-2: #1c2821;
  --text: #edf2ee;
  --muted: #a3b0a8;
  --border: #2b3a31;
  --danger-soft: #3d1d1a;
  --success-soft: #173826;
  --warning-soft: #3a2f12;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg); background-attachment: fixed; background-size: cover; background-position: center; }
img { max-width: 100%; display: block; }
a { color: var(--primary); }
[data-theme="dark"] a { color: #8fd3b0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.boot img { animation: pulse 1.6s ease-in-out infinite; }

/* ---------- Estrutura ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--primary); color: #fff; box-shadow: 0 2px 14px rgba(0, 0, 0, .15); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand img { width: 40px; height: 46px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .25)); }
.brand strong { font-family: var(--serif); font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-size: 11px; color: #f3d77a; letter-spacing: .08em; text-transform: uppercase; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .12); color: inherit; text-decoration: none; }
.icon-btn:hover { background: rgba(255, 255, 255, .22); }
.badge-count { position: absolute; top: -4px; right: -4px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: #1d2621; font-size: 11px; font-weight: 800; line-height: 19px; text-align: center; }
.top-search { display: none; }
.avatar-btn { border: 2px solid rgba(255, 255, 255, .5); padding: 0; background: none; border-radius: 50%; }

.nav { position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(300px, 86vw); display: flex; flex-direction: column; gap: 2px; padding: 18px 12px; padding-top: calc(18px + env(safe-area-inset-top)); background: var(--surface); box-shadow: var(--shadow-lg); transform: translateX(-105%); transition: transform .25s ease; overflow-y: auto; }
.nav.open { transform: none; }
.nav-head { display: flex; align-items: center; gap: 10px; padding: 0 8px 14px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.nav-head img { width: 44px; height: 52px; object-fit: contain; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: var(--text); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
[data-theme="dark"] .nav a.active { color: #a8e3c4; }
.nav a svg { color: var(--accent); }
.nav-search { margin: 4px 4px 10px; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(10, 20, 15, .45); opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.show { opacity: 1; pointer-events: auto; }

main.page { width: 100%; max-width: 1200px; margin: 0 auto; padding: 18px 14px calc(40px + env(safe-area-inset-bottom)); animation: fadeIn .3s ease; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 28px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-head h2 { font-size: 21px; }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-body { padding: 16px; }
.card.interactive { transition: transform .18s ease, box-shadow .18s ease; cursor: pointer; text-decoration: none; color: inherit; display: block; }
.card.interactive:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--primary-soft); }
.card h3 { font-size: 18px; margin-bottom: 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 13px; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.grid-photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.grid-photos button, .grid-photos a { position: relative; padding: 0; border: 0; border-radius: 12px; overflow: hidden; background: var(--primary-soft); aspect-ratio: 1; }
.grid-photos img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.grid-photos button:hover img, .grid-photos a:hover img { transform: scale(1.05); }
.photo-badges { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 4px; }
.photo-badges span { padding: 2px 7px; border-radius: 10px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 700; text-decoration: none; white-space: nowrap; transition: background .15s, transform .1s; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-gold { background: var(--accent); border-color: var(--accent); color: #1d2621; }
.btn-gold:hover:not(:disabled) { filter: brightness(.95); background: var(--accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8f1c13; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn.liked { color: #d0335a; border-color: #f2c3cf; }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700; }
[data-theme="dark"] .chip { color: #a8e3c4; }
.chip.gold { background: var(--accent-soft); color: #7a5c00; }
[data-theme="dark"] .chip.gold { color: #f3d77a; }
.chip.red { background: var(--danger-soft); color: var(--danger); }
.chip.gray { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips button { flex: none; border: 1px solid var(--border); background: var(--surface); padding: 7px 14px; border-radius: 999px; font-weight: 600; }
.chips button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden; background: var(--accent-soft); color: #7a5c00; font-weight: 800; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.empty { display: grid; justify-items: center; gap: 10px; padding: 36px 18px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty svg { color: var(--accent); }
.empty p { margin: 0; max-width: 420px; font-size: 16px; }

.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--radius); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent); animation: shimmer 1.3s infinite; }
[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent); }
.sk-card { height: 240px; }
.sk-line { height: 14px; margin: 8px 0; border-radius: 6px; }

/* ---------- Formulários ---------- */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 700; color: var(--muted); }
.field .req { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
textarea { min-height: 110px; resize: vertical; }
input[type=color] { width: 56px; height: 44px; padding: 3px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.form-error { padding: 10px 12px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.switch:last-child { border-bottom: 0; }
.switch input { width: 44px; height: 24px; appearance: none; border-radius: 12px; background: var(--border); position: relative; transition: background .2s; flex: none; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(20px); }
.switch span small { display: block; color: var(--muted); font-size: 12px; }
.uploader { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.uploader .preview { width: 96px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); }
.uploader .previews { display: flex; gap: 6px; flex-wrap: wrap; }
.uploader .previews img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- Modal e avisos ---------- */
dialog#modal { width: min(640px, calc(100% - 20px)); max-height: calc(100dvh - 20px); padding: 0; border: 0; border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog#modal.wide { width: min(980px, calc(100% - 20px)); }
dialog::backdrop { background: rgba(10, 20, 15, .55); backdrop-filter: blur(3px); }
dialog[open] { animation: pop .2s ease; }
.modal-shell { display: flex; flex-direction: column; max-height: calc(100dvh - 20px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 20px; }
.modal-head .icon-btn { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }

#toasts { position: fixed; z-index: 100; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 24px)); }
.toast { padding: 12px 16px; border-radius: 14px; background: var(--primary); color: #fff; box-shadow: var(--shadow-lg); font-weight: 600; animation: slideUp .25s ease; }
.toast.error { background: var(--danger); }
.toast.info { background: #2d3b33; }

/* ---------- Início ---------- */
.hero { position: relative; display: grid; justify-items: center; gap: 10px; padding: 30px 18px; text-align: center; border-radius: 26px; background: radial-gradient(circle at 50% 0%, #2c6b50, var(--primary-dark)); color: #fff; overflow: hidden; box-shadow: var(--shadow-lg); }
.hero::before { content: ""; position: absolute; inset: 0; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cpath d='M30 4l4 10 10 1-8 7 3 10-9-6-9 6 3-10-8-7 10-1z' fill='%23c9a227' fill-opacity='.07'/%3E%3C/svg%3E"); }
.hero > * { position: relative; }
.hero img.crest { width: 130px; height: 152px; object-fit: contain; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .35)); animation: float 6s ease-in-out infinite; }
.hero h1 { font-size: 34px; color: #fff; }
.hero p { margin: 0; max-width: 620px; color: #e7efe9; }
.hero .divider { width: 70px; height: 3px; border-radius: 2px; background: var(--accent); }
.countdown { position: absolute; top: 12px; right: 12px; padding: 4px 10px; border-radius: 999px; background: var(--accent); color: #1d2621; font-size: 12px; font-weight: 800; }
.cover-wrap { position: relative; }
.birthday { display: flex; align-items: center; gap: 12px; padding: 12px; }
.birthday .when { margin-left: auto; text-align: right; }
.birthday .when b { display: block; color: var(--primary); font-size: 18px; }
[data-theme="dark"] .birthday .when b { color: #a8e3c4; }
.birthdays { display: grid; grid-template-columns: 1fr; gap: 10px; }

/* ---------- Calendário ---------- */
.calendar { padding: 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cal-head h2 { font-size: 20px; text-transform: capitalize; text-align: center; flex: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 800; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.cal-day { position: relative; min-height: 52px; padding: 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); text-align: left; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-day .num { font-weight: 700; font-size: 13px; }
.cal-day.other { opacity: .35; }
.cal-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.busy { background: var(--primary-soft); }
.cal-day.blocked { background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 6px, var(--border) 6px, var(--border) 7px); color: var(--muted); }
.cal-day.past { color: var(--muted); }
.cal-day:hover:not(:disabled) { border-color: var(--primary); }
.cal-dot { display: block; height: 6px; border-radius: 3px; background: var(--primary); }
.cal-dot.pending { background: var(--accent); }
.cal-label { display: none; font-size: 11px; line-height: 1.25; padding: 2px 5px; border-radius: 6px; background: var(--primary); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-label.pending { background: var(--accent); color: #1d2621; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -2px; }
.event-row { display: flex; gap: 12px; align-items: center; padding: 12px; }
.date-box { flex: none; width: 58px; text-align: center; border-radius: 12px; background: var(--primary); color: #fff; padding: 6px 0; }
.date-box b { display: block; font-size: 22px; line-height: 1; }
.date-box small { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #f3d77a; }

/* ---------- Notícias ---------- */
.article { max-width: 780px; margin: 0 auto; }
.article .card-cover { aspect-ratio: 21 / 9; }
.article-body { white-space: pre-line; font-size: 16px; line-height: 1.75; }
.comment { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: 0; }
.comment p { margin: 2px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.comment.hidden-comment { opacity: .55; }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 90; display: grid; grid-template-rows: auto 1fr auto; background: rgba(5, 10, 8, .94); color: #fff; animation: fadeIn .2s; }
.lightbox .lb-top, .lightbox .lb-bottom { display: flex; align-items: center; gap: 8px; padding: 10px 12px; flex-wrap: wrap; }
.lightbox .lb-top { padding-top: calc(10px + env(safe-area-inset-top)); }
.lightbox .lb-bottom { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.lightbox .lb-stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 0 8px; touch-action: pan-y; }
.lightbox .lb-stage img { max-height: 100%; max-width: 100%; object-fit: contain; border-radius: 8px; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.lightbox .lb-prev { left: 8px; }
.lightbox .lb-next { right: 8px; }
.lightbox .btn { background: rgba(255, 255, 255, .12); border-color: transparent; color: #fff; }
.lightbox .btn:hover:not(:disabled) { background: rgba(255, 255, 255, .22); }
.lightbox .lb-comments { width: 100%; max-height: 32vh; overflow-y: auto; background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 8px 12px; }
.lightbox .lb-comments input { background: rgba(255, 255, 255, .1); border-color: transparent; color: #fff; }

/* ---------- Marketing ---------- */
.ad-gallery { display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x mandatory; }
.ad-gallery img { flex: none; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; scroll-snap-align: start; }
.price { font-weight: 800; color: var(--primary); }
[data-theme="dark"] .price { color: #a8e3c4; }
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.searchbox { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--muted); }
.searchbox input { border: 0; background: transparent; min-height: 44px; padding: 0; outline: none; }

/* ---------- História ---------- */
.story { display: grid; gap: 14px; }
.story-card { display: grid; grid-template-columns: 1fr; }
.story-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.story-card p { white-space: pre-line; margin: 6px 0 0; }
.timeline { position: relative; margin: 0; padding: 0 0 0 26px; list-style: none; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: linear-gradient(var(--accent), var(--primary)); }
.timeline li { position: relative; margin-bottom: 14px; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 18px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.timeline button.tl-item { width: 100%; text-align: left; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 12px 14px; box-shadow: var(--shadow); }
.timeline .year { font-family: var(--serif); font-size: 22px; font-weight: 700; color: var(--accent); }
.timeline .tl-detail { margin-top: 8px; color: var(--muted); white-space: pre-line; }
.history-nav { position: sticky; top: 66px; z-index: 5; background: var(--bg); padding: 8px 0; }

/* ---------- Árvore ---------- */
.tree-viewport { position: relative; height: 70vh; min-height: 420px; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border); background: radial-gradient(circle at center, var(--surface), var(--surface-2)); touch-action: none; cursor: grab; }
.tree-viewport.dragging { cursor: grabbing; }
.tree-canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; padding: 40px; }
.tree-controls { position: absolute; right: 10px; top: 10px; z-index: 2; display: flex; flex-direction: column; gap: 6px; }
.tree-controls .icon-btn { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); }
.ftree, .ftree ul { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; }
.ftree ul { position: relative; padding-top: 24px; }
.ftree li { position: relative; display: flex; flex-direction: column; align-items: center; padding: 24px 8px 0; }
.ftree > li { padding-top: 0; }
.ftree li::before, .ftree li::after { content: ""; position: absolute; top: 0; right: 50%; width: 50%; height: 24px; border-top: 2px solid var(--accent); }
.ftree li::after { right: auto; left: 50%; border-left: 2px solid var(--accent); }
.ftree li:only-child::before, .ftree li:only-child::after { display: none; }
.ftree li:only-child { padding-top: 24px; }
.ftree > li:only-child { padding-top: 0; }
.ftree li:first-child::before, .ftree li:last-child::after { border: 0 none; }
.ftree li:last-child::before { border-right: 2px solid var(--accent); border-radius: 0 8px 0 0; }
.ftree li:first-child::after { border-radius: 8px 0 0 0; }
.ftree ul::before { content: ""; position: absolute; top: 0; left: 50%; height: 24px; border-left: 2px solid var(--accent); }
.ftree li:only-child > .couple::before { content: ""; position: absolute; top: -24px; left: 50%; height: 24px; border-left: 2px solid var(--accent); }
.ftree > li:only-child > .couple::before { display: none; }
.couple { position: relative; display: flex; align-items: stretch; gap: 6px; padding: 6px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.person { width: 120px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px; border: 0; border-radius: 12px; background: transparent; text-align: center; font-size: 12px; }
.person:hover { background: var(--surface-2); }
.person b { font-size: 13px; line-height: 1.2; }
.person small { color: var(--muted); }
.person.deceased .avatar { filter: grayscale(.8); }
.person.female .avatar { box-shadow: 0 0 0 3px #e7b8c8; }
.person.male .avatar { box-shadow: 0 0 0 3px #b8cde7; }
.couple .heart { align-self: center; color: var(--accent); }
.toggle-branch { position: absolute; bottom: -13px; left: 50%; transform: translateX(-50%); width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--accent); background: var(--surface); color: var(--text); font-weight: 800; line-height: 1; z-index: 1; }
.ref-note { font-size: 11px; color: var(--muted); padding: 4px 8px; }

/* ---------- Jogos ---------- */
.game-card .game-icon { display: grid; place-items: center; height: 120px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--accent); }
.quiz-option { display: block; width: 100%; text-align: left; padding: 14px 16px; margin-bottom: 8px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); font-weight: 600; }
.quiz-option:hover:not(:disabled) { border-color: var(--primary); }
.quiz-option.correct { border-color: var(--success); background: var(--success-soft); }
.quiz-option.wrong { border-color: var(--danger); background: var(--danger-soft); }
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .3s; }
.memory-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 640px; margin: 0 auto; }
.memory-card { aspect-ratio: 1; padding: 0; border: 0; border-radius: 14px; perspective: 600px; background: transparent; }
.memory-card .inner { position: relative; width: 100%; height: 100%; transition: transform .4s; transform-style: preserve-3d; }
.memory-card.flipped .inner, .memory-card.matched .inner { transform: rotateY(180deg); }
.memory-card .face { position: absolute; inset: 0; border-radius: 14px; backface-visibility: hidden; overflow: hidden; }
.memory-card .back { display: grid; place-items: center; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.memory-card .back img { width: 46%; opacity: .9; }
.memory-card .front { transform: rotateY(180deg); }
.memory-card .front img { width: 100%; height: 100%; object-fit: cover; }
.memory-card.matched { opacity: .75; }
.ranking li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.ranking .pos { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface-2); }
.ranking li:nth-child(1) .pos { background: #f3d77a; color: #5c4500; }
.ranking li:nth-child(2) .pos { background: #dfe3e8; color: #3b4450; }
.ranking li:nth-child(3) .pos { background: #e8c3a0; color: #5b3615; }
.ranking li.me { background: var(--accent-soft); border-radius: 10px; padding-inline: 8px; }
ol.ranking { list-style: none; margin: 0; padding: 0; }

/* ---------- Melhores do Ano ---------- */
.poll-option { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; margin-bottom: 8px; border: 2px solid var(--border); border-radius: 14px; background: var(--surface); text-align: left; position: relative; overflow: hidden; }
.poll-option.mine { border-color: var(--accent); }
.poll-option .bar { position: absolute; inset: 0 auto 0 0; background: var(--primary-soft); z-index: 0; transition: width .5s; }
.poll-option > *:not(.bar) { position: relative; z-index: 1; }
.poll-option .pct { margin-left: auto; font-weight: 800; }

/* ---------- Perfil e configurações ---------- */
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 22px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tabs a, .tabs button { flex: none; padding: 10px 14px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font-weight: 700; text-decoration: none; }
.tabs .active { border-color: var(--accent); color: var(--text); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 160px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: inherit; }
.stat b { display: block; font-size: 26px; font-family: var(--serif); color: var(--primary); }
[data-theme="dark"] .stat b { color: #a8e3c4; }
.stat.alert b { color: var(--danger); }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: #6b5000; }
[data-theme="dark"] .notice { color: #f3d77a; }
.notif { display: flex; gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.notif.unread { background: var(--primary-soft); }
.notif:last-child { border-bottom: 0; }
.notif p { margin: 2px 0 0; color: var(--muted); }

/* ---------- Login ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% -10%, #2c6b50, var(--primary-dark) 70%); }
.auth-card { width: min(440px, 100%); padding: 26px 22px; border-radius: 26px; background: var(--surface); box-shadow: var(--shadow-lg); animation: pop .3s ease; }
.auth-card .crest { width: 110px; height: 128px; margin: -80px auto 6px; object-fit: contain; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .35)); }
.auth-card h1 { text-align: center; font-size: 28px; }
.auth-card .sub { text-align: center; color: var(--muted); margin: 4px 0 18px; }

/* ---------- Animações ---------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes pulse { 50% { opacity: .5; } }
@keyframes float { 50% { transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Telas maiores ---------- */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .grid-photos { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid .full { grid-column: 1 / -1; }
  .birthdays { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .toolbar { flex-direction: row; align-items: center; }
  .toolbar .searchbox { flex: 1; }
  .cal-day { min-height: 76px; }
  .cal-label { display: block; }
  .cal-dot { display: none; }
  .memory-grid { grid-template-columns: repeat(4, 1fr); }
  .hero h1 { font-size: 44px; }
  .story-card { grid-template-columns: 280px 1fr; }
  .story-card img { height: 100%; aspect-ratio: auto; }
  .profile-head { flex-direction: row; text-align: left; }
}
@media (min-width: 1024px) {
  .topbar { padding-inline: 24px; }
  .top-search { display: flex; flex: 1; max-width: 420px; margin-left: 24px; }
  .top-search input { background: rgba(255, 255, 255, .14); border: 0; color: #fff; }
  .top-search input::placeholder { color: rgba(255, 255, 255, .7); }
  .menu-btn { display: none; }
  .nav { position: sticky; top: 66px; inset: auto; z-index: 20; width: auto; flex-direction: row; justify-content: center; flex-wrap: wrap; padding: 8px 16px; transform: none; box-shadow: 0 1px 0 var(--border); border-radius: 0; overflow: visible; }
  .nav-head, .nav-search { display: none; }
  .nav a { padding: 8px 12px; font-size: 14px; }
  .scrim { display: none; }
  main.page { padding: 26px 24px 60px; }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
  .grid-photos { grid-template-columns: repeat(4, 1fr); }
  .birthdays { grid-template-columns: repeat(3, 1fr); }
  .stat-grid { grid-template-columns: repeat(5, 1fr); }
  .layout-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
  .memory-grid { grid-template-columns: repeat(6, 1fr); max-width: 900px; }
}
