:root {
    --bg: #f6f4ee;
    --surface: #ffffff;
    --surface-2: #eef3f1;
    --text: #1d2a27;
    --muted: #63706c;
    --border: #dfe3df;
    --accent: #0f766e;
    --accent-contrast: #ffffff;
    --user-bubble: #0f766e;
    --user-text: #ffffff;
    --danger: #b42318;
    --brand-soal: #0f766e;
    --brand-agama: #a16207;
    --brand-id: #c8102e;
    --radius: 16px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1514;
        --surface: #172120;
        --surface-2: #1d2b29;
        --text: #e5ece9;
        --muted: #93a39e;
        --border: #2a3a37;
        --accent: #2dd4bf;
        --accent-contrast: #062421;
        --user-bubble: #115e59;
        --user-text: #ecfdf9;
        --danger: #f97066;
        --brand-soal: #2dd4bf;
        --brand-agama: #fbbf24;
        --brand-id: #f87171;
    }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app {
    max-width: 820px;
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 0 16px;
}

.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand h1 { margin: 0; font-size: 1.1rem; }
.brand p { margin: 0; font-size: .85rem; color: var(--muted); }

.brand-soal { color: var(--brand-soal); }
.brand-agama { color: var(--brand-agama); }
.brand-id { color: var(--brand-id); font-size: .82em; }
.brand .brand-name { font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.15; }
.brand .brand-by { font-size: .78rem; }
.brand-by a { color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 1px dotted currentColor; }
.brand-by a:hover { color: var(--brand-agama); }

.logo {
    width: 40px; height: 40px; flex: none;
    display: grid; place-items: center;
    border-radius: 12px;
    background: var(--accent); color: var(--accent-contrast);
    font-size: 1.3rem;
}

button { font: inherit; cursor: pointer; }

.ghost {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    border-radius: 999px;
    padding: 6px 14px;
}
.ghost:hover { background: var(--surface-2); }

.chat {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.welcome h2 { margin: 0 0 6px; font-size: 1.25rem; }
.welcome p { margin: 0 0 14px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: .9rem;
    text-align: left;
}
.chip:hover { border-color: var(--accent); }

.sites { margin-top: 16px; font-size: .9rem; color: var(--muted); }
.sites summary { cursor: pointer; }
.sites ul { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 0 0; margin: 0; list-style: none; }
.sites a { color: var(--accent); }

.msg { display: flex; }
.msg.user { justify-content: flex-end; }

.bubble {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: var(--radius);
    overflow-wrap: anywhere;
}
.user .bubble {
    background: var(--user-bubble);
    color: var(--user-text);
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}
.bot .bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.bot .bubble p { margin: 0 0 10px; }
.bot .bubble p:last-child { margin-bottom: 0; }
.bot .bubble ul, .bot .bubble ol { margin: 0 0 10px; padding-left: 22px; }
.bot .bubble.error { border-color: var(--danger); color: var(--danger); }

.cite {
    font-size: .72em;
    vertical-align: super;
    line-height: 0;
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    margin-left: 1px;
}

.sources {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: .88rem;
}
.sources h3 { margin: 0 0 6px; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sources ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.sources li { display: flex; gap: 8px; }
.sources .num { color: var(--accent); font-weight: 600; flex: none; }
.sources a { color: var(--text); }
.sources .site { color: var(--muted); }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: .82rem;
}
.action:hover { color: var(--accent); border-color: var(--accent); }
.action:disabled { cursor: default; color: var(--accent); }

/* Dokumen sumber PDF (dirender oleh html2pdf, selalu terang) */
.pdf-doc {
    width: 182mm;
    color: #1d2a27;
    background: #fff;
    font: 11pt/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.pdf-doc h1 { margin: 0 0 12px; font-size: 18pt; font-weight: 800; }
.pdf-doc .brand-soal { color: #0f766e; }
.pdf-doc .brand-agama { color: #a16207; }
.pdf-doc .brand-id { color: #c8102e; }
.pdf-doc .q { margin: 0 0 14px; padding: 10px 12px; background: #eef3f1; border-radius: 8px; }
.pdf-doc .a p { margin: 0 0 8px; }
.pdf-doc .a ul, .pdf-doc .a ol { margin: 0 0 8px; padding-left: 20px; }
.pdf-doc .cite { color: #0f766e; text-decoration: none; font-size: .72em; vertical-align: super; }
.pdf-doc h3 { margin: 16px 0 6px; font-size: 10pt; text-transform: uppercase; letter-spacing: .04em; color: #63706c; }
.pdf-doc > ol { font-size: 9.5pt; padding-left: 0; list-style: none; }
.pdf-doc a { color: #0f766e; overflow-wrap: anywhere; }
.pdf-doc footer {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #dfe3df;
    font-size: 9.5pt;
    color: #63706c;
    text-align: center;
}

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--muted);
    animation: blink 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
    flex: 1;
    border: 0;
    outline: 0;
    resize: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    padding: 6px 8px;
    max-height: 160px;
}
.composer button {
    width: 42px; height: 42px; flex: none;
    border: 0; border-radius: 12px;
    background: var(--accent); color: var(--accent-contrast);
    display: grid; place-items: center;
}
.composer button:disabled { opacity: .5; cursor: not-allowed; }

.disclaimer {
    margin: 8px 0 14px;
    font-size: .78rem;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 560px) {
    .bubble { max-width: 94%; }
}

/* ---------- Halaman form (ajukan situs) ---------- */
.page { max-width: 640px; margin: 0 auto; padding: 0 16px 40px; }
.page .brand { text-decoration: none; color: inherit; }
.page .ghost { text-decoration: none; font-size: .9rem; }

.btn-outline {
    display: inline-block;
    margin-top: 12px;
    padding: 6px 14px;
    border: 1px dashed var(--accent);
    border-radius: 999px;
    color: var(--accent);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 600;
}
.btn-outline:hover { background: var(--surface-2); border-style: solid; }

.form-card {
    margin-top: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.form-card h2 { margin: 0 0 6px; font-size: 1.3rem; }
.form-card .muted { color: var(--muted); margin: 0 0 20px; }
.form-card form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: .92rem; font-weight: 600; }
.field em { font-weight: 400; font-style: normal; }
.field input, .field textarea {
    font: inherit;
    font-weight: 400;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    resize: vertical;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.field .err { color: var(--danger); font-weight: 500; }
.field.captcha input { max-width: 120px; }
.field.captcha strong { color: var(--brand-agama); font-size: 1.05rem; }

.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.form-error {
    padding: 10px 14px;
    margin-bottom: 16px;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    color: var(--danger);
    font-size: .92rem;
}

.btn-primary {
    display: inline-block;
    align-self: flex-start;
    border: 0;
    border-radius: 10px;
    padding: 11px 20px;
    background: var(--accent);
    color: var(--accent-contrast);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }

.success { text-align: center; padding: 12px 0; }
.success p { color: var(--muted); margin: 0 0 20px; }
