/* =========================================================
   Tambahan gaya untuk versi online
   ========================================================= */

/* ---------- boot & mode ---------- */
.boot-screen { position: fixed; inset: 0; display: none; place-items: center; background: var(--bg); z-index: 200; }
body.booting .boot-screen { display: grid; }
body.booting .app, body.booting .landing { visibility: hidden; }
.spin-in { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); opacity: .8; } }

.landing { display: none; }
body[data-mode="landing"] .app { display: none; }
body[data-mode="landing"] .landing { display: block; }
body[data-mode="account"] .topbar-search,
body[data-mode="account"] #btn-add,
body[data-mode="account"] .sync-pill,
body[data-mode="public"] .sync-pill { display: none !important; }

/* sembunyikan kontrol edit untuk pembaca/publik */
body.ro .edit-only, body.ro .add-chip, body.ro .pchip-x, body.ro [data-dact="edit"] { display: none !important; }
body:not(.is-owner) .owner-only { display: none !important; }

/* ---------- sidebar ---------- */
.family-switch:empty { display: none; }
.family-switch { margin: -8px 0 16px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.fs-name { font-weight: 800; color: var(--gold); font-size: 14.5px; line-height: 1.3; }
.fs-meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.fs-link { display: inline-block; margin-top: 8px; font-size: 12.5px; font-weight: 650; }
.user-chip { padding: 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.uc-row { display: flex; align-items: center; gap: 10px; }
.uc-row .avatar { color: var(--primary); }
.uc-info { min-width: 0; flex: 1; }
.uc-info b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-info small { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-row .icon-btn { width: 32px; height: 32px; font-size: 14px; }
.uc-guest { display: flex; flex-direction: column; gap: 6px; }

/* ---------- topbar ---------- */
.sync-pill { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 99px; white-space: nowrap; border: 1px solid var(--border); color: var(--muted); }
.sync-pill.ok { color: var(--primary); background: var(--primary-soft); border-color: transparent; }
.sync-pill.saving { color: var(--gold); background: var(--gold-soft); border-color: transparent; }
.sync-pill.err { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.sync-pill:empty { display: none; }
.public-banner:empty { display: none; }
.public-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 16px 28px 0; padding: 12px 16px; border-radius: 14px; background: var(--gold-soft); color: var(--text); font-size: 13.5px; font-weight: 600; }

.loading-block { display: grid; place-items: center; gap: 12px; padding: 80px 20px; color: var(--muted); }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- landing ---------- */
.landing { min-height: 100vh; background:
  radial-gradient(900px 600px at 0% 0%, rgba(47, 179, 131, .16), transparent 60%),
  radial-gradient(800px 600px at 100% 100%, rgba(219, 183, 94, .14), transparent 60%), var(--bg); }
.landing-grid { max-width: 1180px; margin: 0 auto; padding: 48px 28px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 48px; align-items: center; min-height: 100vh; }
.landing-hero .brand { padding: 0 0 26px; }
.landing-hero h1 { font-size: clamp(32px, 4.2vw, 52px); font-weight: 800; letter-spacing: -1px; line-height: 1.1; }
.landing-hero h1 span { background: linear-gradient(90deg, var(--gold), #f1d27f); -webkit-background-clip: text; background-clip: text; color: transparent; }
.landing-hero .lead { font-size: 16px; color: var(--text-2); max-width: 600px; margin: 16px 0 26px; }
.features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 26px; }
.feat { display: grid; grid-template-columns: 38px 1fr; column-gap: 12px; padding: 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.feat i { grid-row: span 2; width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-style: normal; background: var(--primary-soft); color: var(--primary); font-size: 17px; }
.feat b { font-size: 13.5px; }
.feat span { font-size: 12px; color: var(--muted); }
.auth-wrap { display: flex; flex-direction: column; gap: 14px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 26px; box-shadow: var(--shadow); }
.auth-card .big { font-size: 46px; }
.auth-card h2 { margin: 6px 0; }
.auth-tabs { width: 100%; margin-bottom: 18px; }
.auth-tabs button { flex: 1; padding: 10px; font-size: 14px; }
#auth-form { display: flex; flex-direction: column; gap: 14px; }
#auth-form .btn { padding: 12px; font-size: 15px; margin-top: 4px; }
.auth-hint { font-size: 12.5px; margin: 0; }

/* ---------- daftar keluarga ---------- */
.family-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.family-card { display: flex; flex-direction: column; gap: 6px; padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-align: left; cursor: pointer; transition: transform .2s var(--ease), border-color .2s, box-shadow .2s; font: inherit; position: relative; overflow: hidden; }
a.family-card:hover, .family-card.add:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: var(--shadow); text-decoration: none; }
a.family-card::after { content: ''; position: absolute; right: -50px; top: -50px; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(var(--gold-soft), transparent 70%); }
.fc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.fc-logo { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; color: #f1d27f; background: linear-gradient(140deg, var(--primary), #0b4a37); font-size: 17px; }
.family-card h3 { font-size: 18px; }
.family-card p { margin: 0; color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fc-stats { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.fc-stats b { color: var(--text); font-size: 15px; }
.fc-foot { font-size: 11.5px; color: var(--muted); margin-top: 6px; padding-top: 10px; border-top: 1px dashed var(--border); }
.family-card.add, .family-card.join { border-style: dashed; border-width: 1.5px; background: transparent; justify-content: center; }
.family-card .plus { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 22px; font-weight: 800; }
.join-row { display: flex; gap: 8px; margin-top: 8px; }
.join-row .input { flex: 1; letter-spacing: 1.5px; font-weight: 700; }

.invite-card { max-width: 520px; margin: 30px auto; text-align: center; padding: 34px 26px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.invite-card .big { font-size: 52px; }
.invite-card h2 { font-size: 26px; color: var(--gold); }
.invite-card p { margin: 0; }

/* ---------- akses ---------- */
.member-row .avatar { color: var(--primary); }
.member-row .icon-btn { width: 32px; height: 32px; font-size: 13px; }
.inv-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 10px; align-items: end; }
.invite-row .code { font-family: ui-monospace, Consolas, monospace; font-weight: 800; letter-spacing: 1.5px; color: var(--gold); background: var(--gold-soft); padding: 6px 10px; border-radius: 9px; }
.invite-row .icon-btn { width: 32px; height: 32px; font-size: 13px; }

/* ---------- aktivitas ---------- */
.activity { display: flex; flex-direction: column; }
.act-row { display: flex; gap: 12px; padding: 11px 4px; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.act-row:last-child { border-bottom: 0; }
.act-row .grow { flex: 1; min-width: 0; }
.act-row .t2 { font-size: 12px; color: var(--muted); }
.act-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); color: var(--text-2); font-weight: 800; }
.act-ic.green { background: var(--primary-soft); color: var(--primary); }
.act-ic.red { background: var(--danger-soft); color: var(--danger); }
.act-ic.gold { background: var(--gold-soft); color: var(--gold); }

/* ---------- data ---------- */
.public-link { display: flex; gap: 8px; }
.public-link .input { flex: 1; font-size: 12.5px; }
.danger-zone { border-color: var(--danger) !important; background: var(--danger-soft) !important; }

@media (max-width: 960px) {
  .landing-grid { grid-template-columns: minmax(0, 1fr); gap: 28px; padding: 28px 18px; }
  .features { grid-template-columns: minmax(0, 1fr); }
  .inv-form { grid-template-columns: 1fr 1fr; }
  .public-banner { margin: 12px 16px 0; }
}

/* perbaikan tata letak */
.inv-form { grid-template-columns: 1fr 1fr; }
.inv-form .btn { grid-column: span 2; }
.join-row .input::placeholder { text-transform: none; letter-spacing: 0; font-weight: 500; }
body[data-mode="public"] .tree-wrap { height: calc(100vh - 215px); }
.member-row .grow, .invite-row .grow { min-width: 0; }

/* =========================================================
   Ramah HP, tema terang, situs publik
   ========================================================= */
.theme-btn { flex-shrink: 0; font-size: 17px; }
.topbar-search + .theme-btn { margin-left: 0; }
.topbar-title { flex: 1; }

/* banner publik ringkas */
.public-banner { padding: 9px 10px 9px 14px; font-size: 13px; font-weight: 500; flex-wrap: nowrap; }
.public-banner .pb-txt { flex: 1; min-width: 0; line-height: 1.45; }
.public-banner .pb-txt b { font-weight: 800; color: var(--gold); }
.public-banner .btn { flex-shrink: 0; }
.pb-x { flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.pb-x:hover { background: var(--surface); color: var(--text); }

/* toolbar pohon: opsi tambahan bisa dilipat (HP) */
.tr-more { display: contents; }
.tr-more-btn { display: none; }
#tr-view { order: 0; }
#tr-root, #tr-mode, #tr-nasab, #tr-orient, #tr-open { order: 1; }
#tr-find { order: 2; }
.tr-dl { order: 3; margin-left: auto; display: flex; gap: 6px; }
.tr-more-btn.on { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* navigasi bawah (HP) */
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .topbar { padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar h1 { font-size: 17px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .page-sub { font-size: 11.5px; }
  .icon-btn.menu-btn, .theme-btn { width: 36px; height: 36px; }
  .public-banner { margin: 10px 14px 0; font-size: 12px; padding: 7px 6px 7px 12px; border-radius: 12px; }
  .public-banner .btn { display: none; }
  .view { padding: 14px 14px 40px; }

  body.has-bnav .view { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  body.has-bnav .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .bottom-nav:not(:empty) {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 22;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, .06);
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 12px; color: var(--muted); font-size: 11px; font-weight: 650; text-decoration: none; -webkit-tap-highlight-color: transparent; }
  .bottom-nav .bn-ic { width: 40px; height: 26px; border-radius: 99px; display: grid; place-items: center; font-size: 15px; transition: background .2s var(--ease); }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a.active .bn-ic { background: var(--primary-soft); }
  body[data-mode="landing"] .bottom-nav { display: none; }
  .sidebar.open ~ .bottom-nav { display: none; }

  /* pohon: bagan memenuhi layar, opsi dilipat */
  .tree-toolbar { gap: 8px; margin-bottom: 10px; }
  .tr-more-btn { display: inline-flex; order: 1; margin-left: auto; }
  #tr-find { order: 2; flex: 1 1 100%; }
  .tr-more { display: none; order: 3; flex: 1 1 100%; flex-wrap: wrap; gap: 8px; padding: 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
  .tr-more.open { display: flex; }
  .tr-more > #tr-root { flex: 1 1 100%; }
  .tr-dl { margin-left: 0; }
  .tree-wrap, body[data-mode="public"] .tree-wrap { height: auto; min-height: 0; }
  .tree-stage { height: 62vh; min-height: 340px; flex: none; }
  .tree-legend { left: 8px; bottom: 8px; right: 60px; gap: 4px 10px; font-size: 11px; padding: 5px 9px; }
  .tree-controls { right: 8px; bottom: 8px; }

  /* beranda: tombol utama selebar kartu */
  .hero-actions .btn { flex: 1 1 100%; justify-content: center; }
  .hero { padding: 22px 20px; }
  .hero h2 { font-size: 24px; }

  /* anggota: filter rapat 2 kolom */
  .member-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
  .member-tools .search { grid-column: 1 / -1; min-width: 0; }
  .member-tools .input { width: 100%; min-width: 0; font-size: 13px; padding-left: 10px; padding-right: 6px; }
}

@media (max-width: 960px) {
  .landing-grid .auth-wrap { order: -1; }
  .landing-grid { min-height: 0; }
}
@media (max-width: 860px) {
  .haul-card { grid-template-columns: 56px 1fr; gap: 12px; }
  .haul-card .cd { display: flex; align-items: baseline; gap: 6px; padding-top: 8px; border-top: 1px dashed var(--border); }
  .haul-card .cd b { display: inline; font-size: 17px; }
}
.back-site { font-weight: 700; font-size: 13.5px; }

/* situs publik: sembunyikan ajakan daftar */
body.site-public .uc-guest { display: none; }
@media (max-width: 860px) { .sync-pill.ok { display: none; } }
