:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg: #f4f5f7;
    --outer-bg: #d1d5db;
    --card-bg: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --ok: #0e9f6e;
    --accent-tint: #eef2ff;
    --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0;
    background: var(--outer-bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.45;
    font-size: 13px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* .page = "kartu HP" ala konek.html: kolom sempit di tengah, kontras
   dengan latar abu-abu di sekelilingnya, biar kerasa mobile walau dibuka
   di layar lebar */
.page {
    width: 100%;
    max-width: 420px;
    padding: 16px;
    min-height: 100vh;
    background: var(--bg);
    box-shadow: 0 0 40px rgba(0,0,0,.15);
}

.page-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 14px;
    width: 100%;
}

.card-center { text-align: center; }

h1 { font-size: 18px; font-weight: 800; margin: 0 0 8px; letter-spacing: -.2px; }
h2 { font-size: 15px; font-weight: 800; margin: 0 0 10px; }
h3 { font-size: 13.5px; font-weight: 800; margin: 0 0 8px; }

.tujuan {
    font-size: 12.5px;
    background: var(--accent-tint);
    border-radius: 12px;
    padding: 10px 12px;
    margin: 0 0 12px;
    line-height: 1.5;
}
.lead { color: var(--muted); margin: 0 0 14px; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.hint { color: var(--muted); font-size: 11px; margin: 4px 0 0; font-weight: 400; }

.info-list {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    font-size: 12.5px;
}
.info-list li { padding: 5px 0; }

.field { margin-bottom: 14px; border: none; padding: 0; }
.field legend { font-weight: 700; margin-bottom: 8px; padding: 0; font-size: 12.5px; }
.field > label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 12.5px; }

.req { color: var(--danger); }
.opt { color: var(--muted); font-weight: 400; font-size: 11px; }

input[type="text"], input[type="email"], input[type="number"], select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 11px;
    font-size: 13.5px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}
/* Panah dropdown cuma buat <select> — input teks biasa nggak perlu */
select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-inline { display: flex; align-items: center; gap: 6px; font-weight: 400; }

/* Toggle button (jenis kelamin, umur, pendidikan) */
.toggle-row { display: flex; gap: 8px; }
.toggle-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle-grid .toggle-btn { flex: 1 1 28%; }
/* Varian: paksa muat 1 baris (buat opsi yang dikit & pendek, mis. pendidikan) */
.toggle-grid-fit { flex-wrap: nowrap; }
.toggle-grid-fit .toggle-btn { flex: 1 1 0; padding-left: 2px; padding-right: 2px; }
.toggle-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 10px 6px;
    font-weight: 700;
    font-size: 12.5px;
    color: var(--muted);
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
}
.toggle-btn input {
    position: absolute;
    width: 1px; height: 1px;
    opacity: 0;
    pointer-events: none;
}
.toggle-btn:has(input:checked) {
    border-color: var(--primary);
    background: var(--accent-tint);
    color: var(--primary);
}

.err { color: var(--danger); font-size: 11.5px; margin-top: 6px; }

.btn {
    display: inline-block;
    padding: 11px 16px;
    border-radius: 11px;
    border: none;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover, .btn-primary:active { background: var(--primary-dark); }
.btn-primary:disabled { background: #c7c9f5; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }

/* Chat bubbles — gaya WhatsApp: kiri/kanan bergantian per pengirim.
   Sengaja TANPA scroll sendiri (ikut scroll halaman) biar nggak ada
   dua scrollbar bertumpuk di satu layar. */
.chat-box {
    background: #e5ddd5;
    border-radius: var(--radius);
    padding: 0 12px 12px;
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow: hidden;
}
/* Header ala WA — bleed full-width nempel di tepi atas chat-box */
.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    margin: 0 -12px 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.chat-header-icon {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--accent-tint);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.chat-header-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.chat-header-name { font-weight: 800; font-size: 13px; color: var(--text); }
.chat-header-members {
    font-size: 10.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Label kecil ala "system message" WA — nunjukin konteks/topik obrolan */
.chat-context { display: flex; justify-content: center; margin: 2px 0 6px; }
.chat-context span {
    background: rgba(0,0,0,.08);
    color: #4b5563;
    font-size: 10.5px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
}

.bubble {
    max-width: 78%;
    border-radius: 10px;
    padding: 6px 10px 7px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.08);
    word-break: break-word;
}
.bubble-other {
    align-self: flex-start;
    background: #fff;
    border-top-left-radius: 2px;
}
.bubble-me {
    align-self: flex-end;
    background: #dcf8c6;
    border-top-right-radius: 2px;
}
.bubble-nama { display: block; font-weight: 700; font-size: 11px; color: var(--primary); }
.bubble-me .bubble-nama { color: #4c8c2b; }
.bubble-pesan { display: block; font-size: 13px; }

/* Option cards (radio/checkbox) */
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option-card {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 10px 13px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.option-card input { width: 17px; height: 17px; flex-shrink: 0; }
.option-card:has(input:checked) {
    border-color: var(--primary);
    background: var(--accent-tint);
}

/* Confidence scale 1-5 */
.scale-row { display: flex; gap: 7px; justify-content: space-between; }
.scale-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 3px;
    cursor: pointer;
    font-weight: 700;
    font-size: 12.5px;
    color: var(--muted);
}
.scale-option input { width: 15px; height: 15px; }
.scale-option:has(input:checked) { border-color: var(--primary); background: var(--accent-tint); color: var(--primary); }
.scale-caption { display: flex; justify-content: space-between; color: var(--muted); font-size: 10.5px; margin-top: 6px; }

/* Progress bar */
.progress-wrap { margin-bottom: 14px; }
.progress-bar { background: #e5e7eb; border-radius: 8px; height: 6px; overflow: hidden; }
.progress-fill { background: var(--primary); height: 100%; transition: width .2s; }
.progress-label { text-align: right; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Halaman kuis: progress nempel atas, tombol Back/Next nempel bawah,
   supaya di HP nggak perlu scroll ke bawah cuma buat pencet Lanjut */
.kuis-page { display: flex; flex-direction: column; padding-bottom: 0; }
.sticky-top {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
    padding-top: 10px;
    margin: -16px -16px 14px;
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 8px;
}
.sticky-bottom {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background: var(--bg);
    margin: 0 -16px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 10px rgba(0,0,0,0.06);
    border-top: 1px solid var(--border);
}

.nav-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.nav-row .btn { flex: 0 0 auto; }
.nav-row .btn-primary { flex: 1; }

.check-icon {
    width: 44px; height: 44px; line-height: 44px;
    border-radius: 50%; background: #e7f7f0; color: var(--ok);
    font-size: 1.3rem; margin: 0 auto 14px;
}

.notice {
    background: #fdf0dc;
    border-radius: 11px;
    padding: 11px 13px;
    margin: 14px 0;
    font-size: 12px;
}

@media (max-width: 400px) {
    .card { padding: 14px 12px; }
    .scale-option { padding: 8px 2px; font-size: 12px; }
    .option-card { padding: 10px 12px; }
    .bubble { max-width: 86%; }
}
