:root {
    --bg: #0b0f16;
    --bg-soft: #121826;
    --surface: rgba(18, 24, 38, .72);
    --surface-2: #161d2c;
    --line: #8b9cb3;
    --text: #f4f7fb;
    --muted: #93a0b5;
    --gold: #e8c572;
    --gold-2: #f5d99a;
    --male: #3b82f6;
    --female: #fb7185;
    --accent: #5eead4;
    --danger: #fb7185;
    --ok: #34d399;
    --stroke: rgba(255,255,255,.1);
    --shadow: 0 18px 50px rgba(0,0,0,.35);
    --radius: 18px;
    --sans: "Plus Jakarta Sans", "Segoe UI", sans-serif;
    --display: "Fraunces", Georgia, serif;
    --admin-bg: #eef1f6;
    --admin-ink: #0f172a;
    --admin-muted: #64748b;
    --admin-side: #0b1220;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--sans);
    color: var(--text);
    background: var(--bg);
}

a { color: inherit; }
button, input, select, textarea { font-family: inherit; }

.public-body {
    min-height: 100vh;
    background:
        radial-gradient(900px 420px at 12% -10%, rgba(232, 197, 114, .16), transparent 55%),
        radial-gradient(800px 400px at 90% 0%, rgba(59, 130, 246, .14), transparent 50%),
        var(--bg);
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.glass-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 14px 16px 0;
    padding: 10px 12px 10px 16px;
    border: 1px solid var(--stroke);
    background: var(--surface);
    backdrop-filter: blur(18px);
    border-radius: 22px;
    box-shadow: var(--shadow);
    z-index: 5;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(145deg, #1e293b, #0b1220);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid var(--stroke);
}
.brand-copy { min-width: 0; }
.kicker {
    margin: 0;
    letter-spacing: .18em;
    font-size: 10px;
    text-transform: uppercase;
    color: var(--gold);
    font-weight: 600;
}
.brand h1 {
    font-family: var(--display);
    font-weight: 560;
    font-size: clamp(16px, 2vw, 22px);
    margin: 1px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.subtitle {
    display: none;
}

.search-cluster {
    flex: 1;
    max-width: 720px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.search-wrap {
    flex: 1;
    min-width: 220px;
    width: auto;
    position: relative;
}
.search-wrap svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    opacity: .55;
    z-index: 1;
}
.search {
    width: 100%;
    border: 1px solid var(--stroke);
    background: rgba(255,255,255,.06);
    color: var(--text);
    border-radius: 999px;
    padding: 10px 14px 10px 40px;
    outline: none;
}
.search::placeholder { color: var(--muted); }
.search:focus { border-color: rgba(232, 197, 114, .55); }

.search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    background: rgba(15, 20, 32, .96);
    border: 1px solid var(--stroke);
    border-radius: 16px;
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 12;
    padding: 6px;
}
.search-hit {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 9px 12px;
    border-radius: 12px;
    cursor: pointer;
    font: inherit;
}
.search-hit strong { font-size: 13px; }
.search-hit span { font-size: 11px; color: var(--gold); }
.search-hit:hover,
.search-hit.is-active { background: rgba(232, 197, 114, .14); }

.view-switch {
    display: flex;
    flex: 0 0 auto;
    align-self: center;
    padding: 3px;
    border-radius: 999px;
    background: rgba(255,255,255,.05);
    border: 1px solid var(--stroke);
}
.view-switch button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
}
.view-switch button.is-active {
    background: rgba(232, 197, 114, .18);
    color: var(--gold-2);
}

.top-actions, .icon-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.legend {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
    padding-right: 6px;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch-circle, .swatch-tri { width: 12px; height: 12px; display: inline-block; }
.swatch-circle {
    border-radius: 50%;
    background: var(--male);
    box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
.swatch-tri {
    width: 0; height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 11px solid var(--female);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--stroke);
    background: rgba(255,255,255,.05);
    color: var(--text);
    padding: 8px 13px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: .18s ease;
}
.btn:hover { background: rgba(255,255,255,.12); }
.btn-solid {
    background: linear-gradient(180deg, #f3d48a, #d7b056);
    color: #1a1408;
    border-color: transparent;
}
.btn-solid:hover { filter: brightness(1.05); color: #1a1408; }
.btn-ghost { background: transparent; }
.btn-danger {
    background: #be123c;
    border-color: #be123c;
    color: #fff;
}
.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 14px;
}
.btn-gold {
    background: rgba(232,197,114,.16);
    border-color: rgba(232,197,114,.3);
    color: var(--gold-2);
}

.canvas-wrap {
    position: relative;
    flex: 1;
    margin: 12px 16px 16px;
    border: 1px solid var(--stroke);
    border-radius: 24px;
    overflow: hidden;
    background:
        radial-gradient(circle at 1px 1px, rgba(255,255,255,.06) 1px, transparent 0) 0 0 / 22px 22px,
        linear-gradient(180deg, #101624, #0b0f16);
    min-height: calc(100vh - 110px);
}
.stage { width: 100%; height: 100%; min-height: calc(100vh - 110px); cursor: grab; touch-action: none; }
.stage:active { cursor: grabbing; }

.hint {
    position: absolute;
    left: 16px;
    bottom: 16px;
    font-size: 12px;
    color: var(--muted);
    pointer-events: none;
    background: rgba(11,15,22,.7);
    border: 1px solid var(--stroke);
    padding: 8px 12px;
    border-radius: 999px;
}

.focus-chip {
    position: absolute;
    left: 16px;
    top: 16px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(520px, calc(100% - 32px));
    background: rgba(15, 20, 32, .88);
    border: 1px solid var(--stroke);
    border-radius: 999px;
    padding: 8px 8px 8px 14px;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}
.focus-chip[hidden] { display: none; }
.focus-chip span {
    font-size: 12px;
    color: var(--gold-2);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.focus-chip button {
    flex: 0 0 auto;
    border: 0;
    background: rgba(232,197,114,.16);
    color: var(--gold-2);
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 999px;
    cursor: pointer;
}

.float-tools {
    position: absolute;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 4;
}

.panel {
    position: absolute;
    top: 16px;
    right: 16px;
    width: min(360px, calc(100% - 32px));
    background: rgba(15, 20, 32, .88);
    border: 1px solid var(--stroke);
    border-radius: 20px;
    padding: 20px 18px 16px;
    box-shadow: var(--shadow);
    display: none;
    backdrop-filter: blur(16px);
    z-index: 6;
}
.panel.open { display: block; animation: rise .22s ease; }
@keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}
.panel h3 {
    font-family: var(--display);
    margin: 0 28px 6px 0;
    font-size: 26px;
}
.panel .meta { color: var(--gold); font-size: 13px; margin-bottom: 10px; }
.panel p { margin: 0 0 14px; font-size: 14px; line-height: 1.6; color: var(--muted); }
.panel .close {
    position: absolute;
    top: 12px;
    right: 12px;
    border: 0;
    background: rgba(255,255,255,.08);
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
}
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.sources-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 20;
    place-items: center;
    padding: 24px;
}
.sources-modal.open { display: grid; }
.sources-card {
    width: min(520px, 100%);
    background: #121826;
    border: 1px solid var(--stroke);
    border-radius: 22px;
    padding: 22px;
    box-shadow: var(--shadow);
}
.sources-card h4 { margin: 0 0 10px; font-family: var(--display); font-size: 24px; }
.sources-card ol { margin: 0; padding-left: 18px; color: var(--muted); }
.empty-state {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 24px;
}
.empty-state .card {
    max-width: 460px;
    background: rgba(18,24,38,.9);
    border: 1px solid var(--stroke);
    color: var(--text);
}

.is-zen .glass-bar,
.is-zen .hint,
.is-zen .focus-chip { display: none; }
.is-zen .canvas-wrap { margin: 0; border-radius: 0; min-height: 100vh; }
.is-zen .stage { min-height: 100vh; }

/* Admin */
.admin-body {
    background: var(--admin-bg);
    color: var(--admin-ink);
}
.shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.side {
    background:
        radial-gradient(420px 220px at 0% 0%, rgba(232,197,114,.12), transparent 60%),
        linear-gradient(180deg, #10192c 0%, #0b1220 100%);
    color: #e8eef8;
    padding: 20px 16px 16px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: sticky;
    top: 0;
    border-right: 1px solid rgba(255,255,255,.06);
}
.side-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    padding: 6px 8px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 18px;
}
.side-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(145deg, #1e293b, #0b1220);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid rgba(255,255,255,.1);
    box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
.side-brand-copy { display: flex; flex-direction: column; min-width: 0; }
.side-brand-copy strong {
    font-family: var(--display);
    font-size: 22px;
    font-weight: 600;
    line-height: 1.1;
}
.side-brand-copy small {
    color: #93a0b5;
    font-size: 12px;
    margin-top: 2px;
}
.side-label {
    margin: 8px 10px 6px;
    font-size: 10px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: #7d8ba3;
    font-weight: 700;
}
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-nav a,
.side-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #d5deec;
    padding: 10px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
}
.nav-icon { flex: 0 0 auto; opacity: .9; }
.side-nav a:hover,
.side-nav a.active {
    background: rgba(232, 197, 114, .14);
    color: #fff;
}
.side-nav a.active {
    box-shadow: inset 3px 0 0 var(--gold);
    color: var(--gold-2);
}
.side-nav a.active .nav-icon { color: var(--gold); }
.side-foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.side-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 12px;
}
.side-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(232,197,114,.16);
    color: var(--gold-2);
    font-size: 12px;
    font-weight: 700;
    flex: 0 0 auto;
}
.side-user-copy { display: flex; flex-direction: column; min-width: 0; }
.side-user-copy strong {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.side-user-copy small { color: #93a0b5; font-size: 11px; }
.side-logout { color: #fda4af; }
.side-logout:hover { background: rgba(251,113,133,.12); color: #fecdd3; }
.main { padding: 32px; }
.admin-body .main h1 { font-family: var(--display); margin: 0 0 6px; font-size: 36px; }
.lead { color: var(--admin-muted); margin: 0 0 20px; }
.admin-body .card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .04);
    color: var(--admin-ink);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 12px 8px; border-bottom: 1px solid #eef2f7; vertical-align: top; }
.table th { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--admin-muted); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #eef2ff;
    color: #1e3a8a;
    font-weight: 600;
}
.admin-body .btn {
    background: #fff;
    color: var(--admin-ink);
    border-color: #dbe3ee;
}
.admin-body .btn:hover { background: #f8fafc; }
.admin-body .btn-solid {
    background: #0f172a;
    color: #fff;
    border-color: #0f172a;
}
.admin-body .btn-gold {
    background: #0f172a;
    color: #fff;
    border-color: #0f172a;
}
.admin-body .search {
    background: #fff;
    color: var(--admin-ink);
    border-color: #dbe3ee;
    padding-left: 14px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 13px; margin-bottom: 4px; color: var(--admin-muted); }
.admin-body input[type=text],
.admin-body input[type=password],
.admin-body input[type=number],
.admin-body input[type=file],
.admin-body select,
.admin-body textarea {
    width: 100%;
    font: inherit;
    padding: 10px 12px;
    border: 1px solid #dbe3ee;
    border-radius: 12px;
    background: #fff;
    color: var(--admin-ink);
}
textarea { min-height: 90px; resize: vertical; }
.alert { padding: 10px 12px; border-radius: 12px; margin-bottom: 14px; }
.alert-ok { background: #d1fae5; color: #065f46; }
.alert-err { background: #ffe4e6; color: #9f1239; }
.alert-info { background: #e0e7ff; color: #312e81; }
.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(700px 280px at 50% 0%, rgba(232,197,114,.2), transparent 70%),
        var(--bg);
    color: var(--text);
}
.login-body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}
.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
}
.login-hero {
    position: relative;
    overflow: hidden;
    padding: 56px 48px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background:
        radial-gradient(700px 360px at 10% -10%, rgba(232,197,114,.22), transparent 55%),
        radial-gradient(520px 280px at 90% 80%, rgba(59,130,246,.16), transparent 50%),
        linear-gradient(165deg, #10192c, #0b1220 70%);
    border-right: 1px solid rgba(255,255,255,.08);
}
.login-hero-inner { max-width: 460px; }
.login-hero-mark { margin-bottom: 22px; }
.login-hero h1 {
    font-family: var(--display);
    font-size: clamp(32px, 4vw, 48px);
    margin: 8px 0 12px;
    line-height: 1.15;
}
.login-hero p { color: var(--muted); margin: 0; line-height: 1.7; max-width: 42ch; }
.login-points {
    list-style: none;
    padding: 0;
    margin: 28px 0 0;
    display: grid;
    gap: 10px;
    color: #dbe4f3;
    font-size: 14px;
    font-weight: 600;
}
.login-points li { display: flex; align-items: center; gap: 10px; }
.login-ornament {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 48px;
    opacity: .9;
}
.login-node {
    width: 28px;
    height: 28px;
    background: var(--male) url("../img/default-laki.svg") center / cover no-repeat;
    border: 2px solid rgba(255,255,255,.7);
}
.login-node.is-male { border-radius: 50%; }
.login-node.is-female {
    width: 30px;
    height: 28px;
    background: var(--female) url("../img/default-perempuan.svg") center / cover no-repeat;
    clip-path: polygon(50% 4%, 100% 96%, 0 96%);
    border: 0;
}
.login-node.sm { width: 18px; height: 18px; }
.login-node.is-female.sm { width: 20px; height: 18px; }
.login-line {
    width: 92px;
    height: 2px;
    background: #8b9cb3;
    margin: 10px 0 0;
}
.login-stem {
    width: 2px;
    height: 28px;
    background: #8b9cb3;
}
.login-kids { display: flex; gap: 22px; margin-top: 8px; }
.login-panel {
    display: grid;
    place-items: center;
    padding: 36px 24px;
    background:
        radial-gradient(500px 240px at 80% 0%, rgba(232,197,114,.08), transparent 60%),
        #0b0f16;
}
.login-card {
    width: min(420px, 100%);
    background: rgba(18, 24, 38, .84);
    border: 1px solid var(--stroke);
    color: var(--text);
    border-radius: 24px;
    padding: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
.login-card h2 {
    font-family: var(--display);
    font-size: 32px;
    margin: 6px 0 8px;
}
.login-lead { color: var(--muted); margin: 0 0 22px; line-height: 1.6; }
.login-form p { margin: 0 0 14px; }
.login-form label { color: #c5d0e0; font-weight: 600; }
.login-field {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--stroke);
    background: rgba(255,255,255,.05);
    border-radius: 14px;
    padding: 0 12px;
}
.login-field .nav-icon { color: var(--gold); opacity: .85; }
.login-field input {
    width: 100%;
    padding: 12px 0;
    border: 0;
    background: transparent;
    color: var(--text);
    outline: none;
}
.login-field:focus-within {
    border-color: rgba(232, 197, 114, .55);
    box-shadow: 0 0 0 3px rgba(232, 197, 114, .12);
}
.login-submit {
    width: 100%;
    margin-top: 6px;
    height: 46px;
    border-radius: 14px;
}
.login-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 14px;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
}
.login-back:hover { color: var(--gold-2); }
.login-wrap label { color: var(--muted); }
.login-wrap input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--stroke);
    background: rgba(255,255,255,.06);
    color: var(--text);
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.stat {
    padding: 18px;
    background: #fff;
    border-radius: 18px;
    border: 1px solid #e2e8f0;
    color: var(--admin-ink);
}
.stat b { display: block; font-size: 32px; font-family: var(--display); }
.children-pick { max-height: 240px; overflow: auto; border: 1px solid #e2e8f0; border-radius: 12px; padding: 8px; }
.children-pick label { display: flex; gap: 8px; align-items: center; margin: 0; padding: 4px 0; color: var(--admin-ink); }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.person-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    background: #e2e8f0;
    display: block;
}
.person-thumb.is-male {
    border-radius: 50%;
    border: 2px solid var(--male);
}
.person-thumb.is-female {
    clip-path: polygon(50% 4%, 100% 96%, 0 96%);
}
.photo-preview-wrap {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}
.photo-preview {
    width: 96px;
    height: 96px;
    object-fit: cover;
    background: #e2e8f0;
    flex: 0 0 auto;
}
.photo-preview.is-male {
    border-radius: 50%;
    border: 3px solid var(--male);
}
.photo-preview.is-female {
    clip-path: polygon(50% 4%, 100% 96%, 0 96%);
}
.photo-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}
.photo-controls small { color: var(--admin-muted); }
.check-inline {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--admin-ink);
    margin: 0;
}
.panel-photo {
    width: 88px;
    height: 88px;
    object-fit: cover;
    display: block;
    margin: 4px 0 12px;
    background: #1e293b;
}
.panel-photo.is-male {
    border-radius: 50%;
    border: 3px solid var(--male);
}
.panel-photo.is-female {
    clip-path: polygon(50% 4%, 100% 96%, 0 96%);
}

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .side {
        position: static;
        min-height: 0;
        padding: 14px;
        display: block;
    }
    .side-brand { margin-bottom: 10px; padding-bottom: 12px; }
    .side-label, .side-user { display: none; }
    .side-nav, .side-foot {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        margin: 0;
        padding: 0;
        border: 0;
    }
    .side-nav a, .side-logout { white-space: nowrap; }
    .form-grid, .stats { grid-template-columns: 1fr; }
    .glass-bar { flex-wrap: wrap; }
    .search-cluster { max-width: none; width: 100%; order: 3; }
    .search-wrap { max-width: none; width: 100%; }
    .legend { display: none; }
    .brand h1 { font-size: 15px; }
    .login-shell { grid-template-columns: 1fr; }
    .login-hero { padding: 32px 24px 24px; border-right: 0; }
    .login-hero h1 { font-size: 32px; }
    .login-ornament { display: none; }
    .login-panel { padding: 8px 16px 32px; }
}
