/* =====================================================================
   AAC Belajar Yuk — gaya
   Warna utama diatur dari Pendamping → Tampilan (variabel CSS di :root).
   ===================================================================== */
@font-face { font-family: 'Baloo 2'; font-weight: 500; font-display: block; src: url(../fonts/baloo-2-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Baloo 2'; font-weight: 600; font-display: block; src: url(../fonts/baloo-2-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Baloo 2'; font-weight: 700; font-display: block; src: url(../fonts/baloo-2-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Baloo 2'; font-weight: 800; font-display: block; src: url(../fonts/baloo-2-latin-800-normal.woff2) format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 400; font-display: swap; src: url(../fonts/nunito-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 600; font-display: swap; src: url(../fonts/nunito-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 700; font-display: swap; src: url(../fonts/nunito-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: swap; src: url(../fonts/nunito-latin-800-normal.woff2) format('woff2'); }

:root {
  --utama: #4F5BD5; --utama-2: #3A45B8; --utama-muda: #E4E8FC;
  --latar: #EEF3FF; --permukaan: #FFFFFF; --permukaan-2: #F6F8FE;
  --tinta: #1C2340; --tinta-2: #5E6789; --tinta-3: #8A93B2; --garis: #DCE3F5;
  --bicara: #1FAA6B; --bicara-2: #178752; --kereta: #E8475C; --kereta-2: #B92E46;
  --bahaya: #D93F4C; --kuning: #FFD24D; --kuning-2: #E0AE12;
  --r: 18px; --r-kecil: 12px; --skala: 1;
  --font-anak: 'Baloo 2', 'Nunito', system-ui, sans-serif;
  --font-ui: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bayang-1: 0 1px 2px rgba(22, 32, 80, .06), 0 2px 8px rgba(22, 32, 80, .05);
  --bayang-2: 0 2px 4px rgba(22, 32, 80, .06), 0 10px 28px rgba(22, 32, 80, .10);
  --celah: 10px; --tinggi-atas: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--latar); color: var(--tinta); font-family: var(--font-ui); font-size: calc(16px * var(--skala));
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; overscroll-behavior: none;
  -webkit-text-size-adjust: 100%; overflow: hidden; touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; border: 0; background: none; padding: 0; }
input, select, textarea { font: inherit; color: inherit; -webkit-user-select: text; user-select: text; }
:focus-visible { outline: 3px solid var(--utama); outline-offset: 2px; }
[hidden] { display: none !important; }
.ik { width: 1.25em; height: 1.25em; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.emo { width: 1em; height: 1em; display: inline-block; vertical-align: -0.12em; object-fit: contain; pointer-events: none; }
/* emoji cadangan (bila tidak ada SVG) */
.emo-t { display: inline-grid; place-items: center; font-style: normal; line-height: 1; font-size: 1em; overflow: visible; }
.tile .sym .emo-t { font-size: 48cqmin; } .wagon .sym .emo-t { font-size: 32px; } .tab .emo-t, .chip .emo-t { font-size: 20px; } .emoji-grid .emo-t { font-size: 26px; } .cepat .emo-t { font-size: 34px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------- Kerangka ---------------- */
#app { height: 100%; display: flex; flex-direction: column; max-width: 1600px; margin: 0 auto; }
.bar-atas {
  height: var(--tinggi-atas); flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 14px;
}
.profil-btn { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 4px 10px 4px 4px; border-radius: 999px; margin-right: auto; }
.profil-btn:active { background: rgba(0,0,0,.04); }
.ava { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: var(--w, #4F5BD5); flex: 0 0 auto; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.ava .emo { width: 28px; height: 28px; }
.profil-teks { min-width: 0; text-align: left; }
.profil-teks b { display: block; font-family: var(--font-anak); font-size: 1.2rem; line-height: 1.05; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profil-teks small { display: block; color: var(--tinta-2); font-weight: 700; font-size: .82rem; white-space: nowrap; }

.segmen { display: flex; background: var(--permukaan); border-radius: 999px; padding: 4px; box-shadow: var(--bayang-1); }
.segmen button { display: flex; align-items: center; gap: 6px; padding: 7px 16px; border-radius: 999px; font-weight: 800; font-family: var(--font-anak); font-size: 1.05rem; color: var(--tinta-2); }
.segmen button[aria-pressed="true"] { background: var(--utama); color: #fff; box-shadow: 0 2px 6px color-mix(in srgb, var(--utama) 40%, transparent); }
.bintang { display: flex; align-items: center; gap: 4px; background: #FFF6D6; border-radius: 999px; padding: 6px 12px 6px 8px; font-weight: 800; font-family: var(--font-anak); font-size: 1.1rem; color: #8A6400; }
.bintang .emo { width: 22px; height: 22px; }
.bintang.dapat { animation: denyut .5s; }
.gigi { --p: 0; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; touch-action: none; -webkit-touch-callout: none;
  background: conic-gradient(var(--utama) calc(var(--p) * 360deg), var(--garis) 0); flex: 0 0 auto; }
.gigi > span { width: 38px; height: 38px; border-radius: 50%; background: var(--permukaan); display: grid; place-items: center; color: var(--tinta-2); pointer-events: none; }
.gigi .ik { width: 22px; height: 22px; }

.layar { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: var(--celah); padding: 0 12px 12px; }

/* ---------------- Kereta kalimat ---------------- */
.kalimat { flex: 0 0 auto; background: var(--permukaan); border-radius: calc(var(--r) + 6px); box-shadow: var(--bayang-1); padding: 10px 12px 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; position: relative; overflow: hidden; }
.jalur { display: flex; align-items: flex-end; gap: 10px; min-width: 0; min-height: 106px; }
.loko { flex: 0 0 auto; width: 92px; position: relative; margin-bottom: -2px; }
.loko svg { width: 100%; height: auto; display: block; }
.loko-badan { fill: var(--kereta); } .loko-kabin { fill: var(--kereta-2); }
.asap { position: absolute; left: 12px; top: -2px; width: 14px; height: 14px; border-radius: 50%; background: #DDE4EF; opacity: 0; }
.jalan .asap { animation: asap 1.1s ease-out infinite; }
.jalan .asap:nth-child(2) { animation-delay: .35s; } .jalan .asap:nth-child(3) { animation-delay: .7s; }
.jalan .loko svg { animation: goyangLoko .35s ease-in-out infinite alternate; }
.gerbong { flex: 1; display: flex; gap: 12px; align-items: flex-end; overflow-x: auto; overflow-y: hidden; padding: 6px 4px 16px; min-width: 0; scroll-behavior: smooth; scrollbar-width: none; }
.gerbong::-webkit-scrollbar { display: none; }
.kosong { align-self: center; margin-bottom: 12px; color: var(--tinta-3); font-family: var(--font-anak); font-weight: 700; font-size: 1.15rem; line-height: 1.2; }
.wagon { flex: 0 0 auto; min-width: 80px; height: 90px; padding: 4px 10px 2px; border: 3px solid var(--b); background: var(--f); border-radius: 16px 16px 10px 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; font-family: var(--font-anak); font-weight: 800; font-size: 1.05rem; color: var(--tinta); }
.wagon::before, .wagon::after { content: ""; position: absolute; bottom: -15px; width: 18px; height: 18px; border-radius: 50%; background: #39405E; box-shadow: inset 0 0 0 5px #39405E, inset 0 0 0 8px #9AA3C0; }
.wagon::before { left: 9px; } .wagon::after { right: 9px; }
.wagon .kait { position: absolute; left: -15px; bottom: 12px; width: 15px; height: 5px; border-radius: 3px; background: #39405E; }
.wagon .sym { font-size: 2.2rem; line-height: 1; height: 44px; display: grid; place-items: center; }
.wagon .sym .emo { width: 40px; height: 40px; }
.wagon .sym img.foto { width: 46px; height: 46px; object-fit: cover; border-radius: 9px; }
.wagon .sym.teks { font-size: 1.4rem; }
.wagon .lbl { line-height: 1.1; white-space: nowrap; }
.wagon.menunggu { border-style: dashed; opacity: .85; }
.wagon.ketik .kursor { display: inline-block; width: 3px; height: 1em; background: var(--tinta); margin-left: 2px; animation: kedip 1s steps(2) infinite; vertical-align: -2px; }
.wagon.masuk { animation: masuk .4s cubic-bezier(.2, 1.4, .4, 1); }
.wagon.aktif { transform: translateY(-8px) scale(1.06); box-shadow: 0 8px 0 -2px var(--b); }
.jalan .wagon { animation: ayun .5s ease-in-out infinite alternate; animation-delay: calc(var(--i) * .12s); }
.rel { grid-column: 1 / -1; height: 18px; margin: 0 -12px;
  background: linear-gradient(#8A6848, #8A6848) 0 2px / 100% 4px no-repeat, repeating-linear-gradient(90deg, #C69C74 0 14px, transparent 14px 32px) 0 6px / 100% 10px no-repeat; }
.jalan .rel { animation: relJalan .6s linear infinite; }

.aksi { display: flex; gap: 8px; align-items: center; padding-bottom: 12px; }
.tbl { border-radius: 16px; font-family: var(--font-anak); font-weight: 800; font-size: 1rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 76px; height: 82px; padding: 6px 10px; box-shadow: 0 5px 0 var(--bb); transition: transform .08s, box-shadow .08s; position: relative; overflow: hidden; }
.tbl:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--bb); }
.tbl .ik { width: 30px; height: 30px; }
.tbl-hapus { background: #FFEBCF; --bb: #E9BB76; color: #7A4A00; }
.tbl-kosong { background: #EEF1F8; --bb: #C7CEDF; color: var(--tinta-2); }
.tbl-bicara { background: var(--bicara); --bb: var(--bicara-2); color: #fff; min-width: 132px; font-size: 1.35rem; }
.tbl-bicara .ik { width: 36px; height: 36px; }

/* ---------------- Area papan ---------------- */
.area { flex: 1 1 auto; min-height: 0; display: grid; gap: var(--celah); grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "tab" "papan"; }
.area .tab-bar { grid-area: tab; }
.area .panel { grid-area: papan; }
body.lebar .area { grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); grid-template-areas: "inti tab" "inti topik"; }
body.lebar .area #panelInti { grid-area: inti; }
body.lebar .area #panelTopik { grid-area: topik; }

.tab-bar { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: none; min-width: 0; }
.tab-bar::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; background: var(--permukaan); border-radius: 14px; padding: 7px 14px 7px 10px;
  font-family: var(--font-anak); font-weight: 700; font-size: 1.05rem; box-shadow: var(--bayang-1); color: var(--tinta); white-space: nowrap; }
.tab .emo { width: 26px; height: 26px; }
.tab[aria-selected="true"] { background: var(--utama); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--utama) 35%, transparent); }

.panel { min-height: 0; min-width: 0; background: rgba(255,255,255,.55); background: color-mix(in srgb, var(--permukaan) 55%, transparent); border-radius: calc(var(--r) + 6px); padding: 10px; display: flex; flex-direction: column; }
.panel-kepala { display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; font-family: var(--font-anak); font-weight: 800; font-size: 1.05rem; color: var(--tinta-2); }
.panel-kepala .emo { width: 22px; height: 22px; }
.panel-isi { flex: 1 1 auto; min-height: 0; overflow: auto; display: block; scrollbar-width: thin; }
/* margin auto: di tengah bila muat, bisa digulir dari kiri bila lebih lebar dari layar */
.panel-isi > .grid { width: max-content; margin: 0 auto; }
.panel-isi > .cepat-grid { width: 100%; }
.grid { display: grid; gap: var(--g, 10px); grid-template-columns: repeat(var(--kol), var(--tile, 110px)); grid-auto-rows: var(--tile-h, calc(var(--tile, 110px) * 1.04)); }

/* ---------------- Tombol kata (tile) ---------------- */
.tile { container-type: size; width: 100%; height: 100%; border: 3px solid var(--b); border-bottom-width: 7px; background: var(--f); border-radius: var(--r);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 3px; transition: transform .08s, border-bottom-width .08s; position: relative; overflow: hidden; color: var(--tinta); }
.tile:active { transform: translateY(3px); border-bottom-width: 4px; }
.tile .sym { flex: 1 1 auto; min-height: 0; width: 100%; display: grid; place-items: center; }
.tile .sym .emo { width: 56%; height: 56%; width: 62cqmin; height: 62cqmin; }
.tile .sym img.foto { width: 64%; height: 64%; width: 70cqmin; height: 70cqmin; object-fit: cover; border-radius: 12%; background: #fff; display: block; }
.tile .sym.teks { font-family: var(--font-anak); font-weight: 800; font-size: 26cqmin; line-height: 1; }
.tile .lbl { flex: 0 0 auto; max-width: 100%; font-family: var(--font-anak); font-size: 13px; font-size: clamp(9px, 16cqi, 26px); font-weight: 800; line-height: 1.05; text-align: center; padding: 0 2px 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .lbl.dua { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .rek { position: absolute; right: 5%; top: 4%; width: 18cqmin; height: 18cqmin; color: var(--tinta-2); opacity: .75; }
.tile.slot { background: transparent; border: 2px dashed rgba(0,0,0,.08); border: 2px dashed color-mix(in srgb, var(--tinta) 10%, transparent); pointer-events: none; }
.tile.mati { opacity: .38; }
.tile.pilih-sel { outline: 4px solid var(--utama); outline-offset: 2px; }
body.label-atas .tile { flex-direction: column-reverse; }
body.kapital .tile .lbl, body.kapital .wagon .lbl { text-transform: uppercase; }
body.tanpa-tulisan .tile .lbl { display: none; }
body.tanpa-tulisan .tile .sym .emo { width: 74cqmin; height: 74cqmin; }
body.tanpa-tulisan .tile .sym img.foto { width: 84cqmin; height: 84cqmin; }
.tile.pantul { animation: pantul .3s; }
.tile.menahan::after, .tbl.menahan::after { content: ""; position: absolute; left: 0; bottom: 0; height: 7px; width: 100%; background: var(--tinta); transform-origin: left; animation: isi var(--durasi, 600ms) linear forwards; }

body.kontras { --garis: #000; }
body.kontras .tile { background: #fff; border-color: var(--b); border-width: 5px; border-bottom-width: 9px; }
body.kontras .tile .lbl { color: #000; }
body.kontras .panel { background: transparent; }

.legenda { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 8px 6px 0; font-size: .82rem; font-weight: 700; color: var(--tinta-2); }
.legenda span { display: inline-flex; align-items: center; gap: 5px; }
.legenda i { width: 12px; height: 12px; border-radius: 4px; background: var(--f); border: 2px solid var(--b); }

/* Kalimat cepat */
.cepat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 10px; width: 100%; }
.cepat { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--permukaan); border: 3px solid var(--garis); border-bottom-width: 6px; border-radius: var(--r); padding: 10px 14px; min-height: 72px;
  font-family: var(--font-anak); font-weight: 800; font-size: 1.2rem; line-height: 1.15; }
.cepat:active { transform: translateY(3px); border-bottom-width: 3px; }
.cepat .emo { width: 42px; height: 42px; }
.cepat.sedang { border-color: var(--bicara); background: color-mix(in srgb, var(--bicara) 10%, white); }
.petunjuk-kosong { color: var(--tinta-2); font-weight: 700; padding: 16px; text-align: center; }

/* ---------------- Scanning ---------------- */
.sorot-grup { outline: 5px solid var(--kuning) !important; outline-offset: 2px; box-shadow: 0 0 0 10px color-mix(in srgb, var(--kuning) 35%, transparent) !important; }
.sorot { outline: 7px solid #FF8A00 !important; outline-offset: 3px; transform: scale(1.05); z-index: 2; }

/* ---------------- Latihan (Mode Main) ---------------- */
.latihan-wrap { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 4px 0 10px; }
.sub { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.sub-btn { display: flex; align-items: center; gap: 8px; background: var(--permukaan); border-radius: 14px; padding: 8px 16px; font-family: var(--font-anak); font-weight: 800; font-size: 1.1rem; box-shadow: var(--bayang-1); }
.sub-btn .emo { width: 26px; height: 26px; }
.sub-btn[aria-pressed="true"] { background: var(--utama); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { flex: 0 0 auto; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--garis); background: var(--permukaan); border-radius: 999px; padding: 4px 12px 4px 6px; font-weight: 800; font-size: .95rem; }
.chip .emo { width: 22px; height: 22px; }
.chip[aria-pressed="true"] { border-color: var(--utama); background: var(--utama-muda); color: var(--utama-2); }
.soal { background: var(--permukaan); border-radius: 24px; padding: 12px 18px 12px 12px; display: flex; align-items: center; gap: 14px; box-shadow: var(--bayang-1); max-width: 100%; }
.dengar { width: 68px; height: 68px; border-radius: 50%; background: var(--kuning); box-shadow: 0 4px 0 var(--kuning-2); display: grid; place-items: center; color: #5C4300; flex: 0 0 auto; }
.dengar .ik { width: 34px; height: 34px; }
.dengar:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--kuning-2); }
.soal p { margin: 0; font-family: var(--font-anak); font-size: clamp(1.4rem, 5vw, 2.2rem); font-weight: 800; line-height: 1.1; }
.soal u { text-decoration-thickness: 4px; text-decoration-color: var(--utama); text-underline-offset: 5px; }
.soal small { display: block; color: var(--tinta-2); font-weight: 700; font-size: 1rem; }
.model { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; background: var(--permukaan); border-radius: 22px; padding: 12px 14px 24px; box-shadow: var(--bayang-1); }
.model .wagon { opacity: .35; filter: grayscale(.6); border-style: dashed; }
.model .wagon.isi { opacity: 1; filter: none; border-style: solid; animation: masuk .4s; }
.model .wagon.giliran { opacity: .75; outline: 3px dashed var(--tinta); outline-offset: 4px; }
.model.jalan .wagon { animation: ayun .5s ease-in-out infinite alternate; animation-delay: calc(var(--i) * .12s); }
.pilihan { display: grid; grid-template-columns: repeat(var(--n, 3), var(--tile, 180px)); grid-auto-rows: calc(var(--tile, 180px) * 1.04); gap: 16px; justify-content: center; }
.tile.salah { animation: goyang .4s; opacity: .35; }
.tile.benar { animation: menang .7s; box-shadow: 0 0 0 6px #fff, 0 0 0 11px var(--bicara); }
.tile.petunjuk { animation: petunjuk 1s ease-in-out infinite; }
.jejak { display: flex; gap: 4px; min-height: 30px; }
.jejak .emo { width: 28px; height: 28px; }

/* ---------------- Lapisan: dialog, lembar, pendamping ---------------- */
.lapisan { position: fixed; inset: 0; z-index: 50; background: rgba(20, 26, 56, .5); display: grid; place-items: center; padding: 16px; animation: muncul .18s; }
.dialog { background: var(--permukaan); border-radius: 26px; width: min(100%, 440px); max-height: calc(100% - 8px); overflow: auto; padding: 22px; box-shadow: var(--bayang-2); position: relative; animation: naik .22s cubic-bezier(.2, .9, .3, 1.1); }
.dialog.lebar { width: min(100%, 720px); }
.dialog h2 { margin: 0 0 6px; font-family: var(--font-anak); font-size: 1.5rem; line-height: 1.15; }
.dialog p { margin: 0 0 12px; color: var(--tinta-2); line-height: 1.45; }
.dialog .tengah { text-align: center; }
.tutup { position: absolute; right: 12px; top: 12px; width: 40px; height: 40px; border-radius: 50%; background: var(--permukaan-2); display: grid; place-items: center; color: var(--tinta-2); }
.tutup .ik { width: 22px; height: 22px; }

.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 16px 0; }
.pin-dots span { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--tinta-2); transition: background .1s; }
.pin-dots span.isi { background: var(--utama); border-color: var(--utama); }
.pin-dots.salah { animation: goyang .4s; }
.pinpad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; justify-content: center; }
.pinpad button { height: 62px; border-radius: 18px; background: var(--permukaan-2); font-size: 1.5rem; font-weight: 800; box-shadow: 0 3px 0 var(--garis); display: grid; place-items: center; }
.pinpad button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--garis); }
.pesan-kecil { min-height: 1.3em; text-align: center; font-weight: 700; font-size: .92rem; color: var(--bahaya); margin: 10px 0 0; }

.pilih-profil { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-top: 14px; }
.pilih-profil button { border: 3px solid var(--garis); border-radius: 22px; padding: 14px 8px; display: grid; justify-items: center; gap: 8px; font-family: var(--font-anak); font-weight: 800; font-size: 1.2rem; background: var(--permukaan); }
.pilih-profil button[aria-current="true"] { border-color: var(--utama); background: var(--utama-muda); }
.pilih-profil .ava { width: 64px; height: 64px; }
.pilih-profil .ava .emo { width: 42px; height: 42px; }

/* Pendamping: layar penuh */
.sheet { position: fixed; inset: 0; z-index: 40; background: var(--latar); display: flex; flex-direction: column; animation: geserMasuk .22s cubic-bezier(.2, .9, .3, 1); font-family: var(--font-ui); -webkit-user-select: text; user-select: text; }
.sheet-atas { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--permukaan); box-shadow: var(--bayang-1); z-index: 1; }
.sheet-atas h1 { margin: 0; font-size: 1.2rem; font-weight: 800; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.teks-sempit { display: none; }
@media (max-width: 420px) { .teks-lebar { display: none; } .teks-sempit { display: inline; } }
.sheet-atas .kembali { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; }
.sheet-atas .kembali:active { background: var(--permukaan-2); }
.sheet-tubuh { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.nav { background: var(--permukaan); border-right: 1px solid var(--garis); overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; font-weight: 700; color: var(--tinta-2); text-align: left; }
.nav button .ik { width: 22px; height: 22px; }
.nav button[aria-current="true"] { background: var(--utama-muda); color: var(--utama-2); }
.isi { overflow: auto; padding: 20px clamp(14px, 3vw, 32px) 40px; }
.isi-dalam { max-width: 920px; margin: 0 auto; }
@media (max-width: 840px) {
  .sheet-tubuh { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .nav { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--garis); padding: 8px 10px; gap: 6px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav button { flex: 0 0 auto; padding: 8px 12px; border-radius: 999px; background: var(--permukaan-2); font-size: .92rem; }
  .nav button .ik { width: 18px; height: 18px; }
  .isi { padding-top: 14px; }
}

/* Komponen formulir pendamping */
.judul-bagian { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.judul-bagian h2 { margin: 0; font-size: 1.45rem; font-weight: 800; }
.judul-bagian p { margin: 2px 0 0; color: var(--tinta-2); flex-basis: 100%; }
.kartu { background: var(--permukaan); border-radius: 18px; box-shadow: var(--bayang-1); padding: 16px; margin-bottom: 14px; }
.kartu h3 { margin: 0 0 10px; font-size: 1.05rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.kartu h3 .ik { color: var(--utama); }
.kartu p { margin: 0 0 10px; color: var(--tinta-2); line-height: 1.5; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 16px; }
.medan { display: grid; gap: 6px; font-weight: 700; font-size: .92rem; color: var(--tinta-2); }
.medan input:not([type=checkbox]):not([type=range]):not([type=color]), .medan select, .medan textarea {
  font-size: 1rem; padding: 11px 12px; border: 1.5px solid var(--garis); border-radius: 12px; background: #fff; color: var(--tinta); font-weight: 600; width: 100%; }
.medan input:focus, .medan select:focus, .medan textarea:focus { outline: none; border-color: var(--utama); box-shadow: 0 0 0 3px var(--utama-muda); }
.medan small { font-weight: 600; color: var(--tinta-3); }
.medan .nilai { color: var(--utama-2); }
input[type=range] { width: 100%; accent-color: var(--utama); }
.saklar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--garis); }
.saklar:last-child { border-bottom: 0; }
.saklar b { display: block; font-weight: 700; }
.saklar small { display: block; color: var(--tinta-2); font-size: .88rem; margin-top: 2px; line-height: 1.4; }
.toggle { position: relative; width: 52px; height: 30px; flex: 0 0 auto; }
.toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: #CBD2E6; transition: background .15s; }
.toggle span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.toggle input:checked + span { background: var(--utama); }
.toggle input:checked + span::after { transform: translateX(22px); }
.pilihan-kartu { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.pilihan-kartu button { border: 2px solid var(--garis); background: #fff; border-radius: 14px; padding: 12px; text-align: left; display: grid; gap: 4px; }
.pilihan-kartu button b { font-weight: 800; }
.pilihan-kartu button small { color: var(--tinta-2); line-height: 1.35; }
.pilihan-kartu button[aria-pressed="true"] { border-color: var(--utama); background: var(--utama-muda); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 18px; border-radius: 12px; font-weight: 800; background: var(--utama); color: #fff; box-shadow: 0 2px 0 var(--utama-2); white-space: nowrap; }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn .ik { width: 20px; height: 20px; }
.btn.sekunder { background: var(--permukaan); color: var(--tinta); box-shadow: inset 0 0 0 1.5px var(--garis); }
.btn.hijau { background: var(--bicara); box-shadow: 0 2px 0 var(--bicara-2); }
.btn.bahaya { background: var(--bahaya); box-shadow: 0 2px 0 #A52C37; }
.btn.teks { background: none; color: var(--utama-2); box-shadow: none; padding: 9px 10px; }
.btn.bahaya-teks { background: none; color: var(--bahaya); box-shadow: none; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.kecil { min-height: 36px; padding: 6px 12px; font-size: .92rem; }
.baris-btn { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.baris-btn.kanan { justify-content: flex-end; }

.stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat > div { background: var(--permukaan); border-radius: 16px; padding: 14px 16px; box-shadow: var(--bayang-1); }
.stat b { display: block; font-size: 1.9rem; font-weight: 800; line-height: 1.1; color: var(--tinta); }
.stat span { font-weight: 700; color: var(--tinta-2); font-size: .9rem; }
.stat em { font-style: normal; font-weight: 800; font-size: .85rem; margin-left: 6px; }
.naik { color: #178752; } .turun { color: var(--bahaya); }
.grafik { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.grafik > div { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--tinta-2); }
.grafik i { width: 100%; max-width: 38px; border-radius: 8px 8px 3px 3px; background: var(--utama); min-height: 3px; opacity: .85; }
.grafik > div.hari-ini i { opacity: 1; background: var(--bicara); }
.batang { display: grid; gap: 8px; }
.batang .br { display: grid; grid-template-columns: minmax(80px, 140px) 1fr 40px; gap: 10px; align-items: center; font-weight: 700; }
.batang .br span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batang .jalur-b { height: 12px; border-radius: 6px; background: var(--permukaan-2); overflow: hidden; }
.batang .jalur-b i { display: block; height: 100%; border-radius: 6px; background: var(--utama); }
.daftar { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.daftar li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--permukaan-2); border-radius: 12px; font-weight: 600; }
.daftar li small { color: var(--tinta-2); white-space: nowrap; font-weight: 700; }
.daftar .aksi-li { display: flex; gap: 4px; flex: 0 0 auto; }
.ikon-btn { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--tinta-2); }
.ikon-btn:active { background: var(--garis); }
.ikon-btn.merah { color: var(--bahaya); }
.ikon-btn .ik { width: 20px; height: 20px; }
.kosong-info { text-align: center; color: var(--tinta-2); padding: 24px 12px; font-weight: 600; }

.kelola { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.kelola .tile { aspect-ratio: 1 / 1.04; height: auto; }
.kelola .tambah { border: 2px dashed var(--garis); border-radius: var(--r); display: grid; place-items: center; align-content: center; gap: 4px; color: var(--utama-2); font-weight: 800; aspect-ratio: 1 / 1.04; }
.kelola .tambah .ik { width: 30px; height: 30px; }
.chip-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 12px; scrollbar-width: thin; }

.papan-edit { overflow: auto; padding: 4px; }
.papan-edit .grid { --tile: 88px; }
.stepper { display: inline-flex; align-items: center; background: var(--permukaan-2); border-radius: 12px; }
.stepper button { width: 40px; height: 40px; display: grid; place-items: center; }
.stepper span { min-width: 32px; text-align: center; font-weight: 800; }

/* Editor kata */
.editor { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 640px) { .editor { grid-template-columns: 1fr; } .editor .pratinjau { justify-self: center; position: static; width: 140px; height: 146px; } }
.pratinjau { width: 170px; height: 177px; position: sticky; top: 0; }
.sumber { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.sumber button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; border-radius: 14px; background: var(--permukaan-2); font-weight: 700; font-size: .9rem; border: 2px solid transparent; }
.sumber button .ik { width: 26px; height: 26px; color: var(--utama); }
.sumber button[aria-pressed="true"] { border-color: var(--utama); background: var(--utama-muda); }
.emoji-picker { max-height: 300px; overflow: auto; border: 1.5px solid var(--garis); border-radius: 14px; padding: 8px; background: #fff; }
.emoji-picker h4 { margin: 8px 4px 4px; font-size: .82rem; color: var(--tinta-2); text-transform: uppercase; letter-spacing: .04em; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; }
.emoji-grid button { aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; }
.emoji-grid button .emo { width: 32px; height: 32px; }
.emoji-grid button[aria-pressed="true"] { background: var(--utama-muda); box-shadow: inset 0 0 0 2px var(--utama); }
.hasil-cari { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 10px; }
.hasil-cari button { aspect-ratio: 1; border: 2px solid var(--garis); background: #fff; border-radius: 12px; padding: 6px; }
.hasil-cari button[aria-pressed="true"] { border-color: var(--utama); }
.hasil-cari img { width: 100%; height: 100%; object-fit: contain; }
.rekam-status { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--tinta-2); margin-top: 8px; }
.rekam-titik { width: 12px; height: 12px; border-radius: 50%; background: var(--bahaya); animation: kedip 1s steps(2) infinite; }

.kamera { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; }
.kamera video { flex: 1; min-height: 0; width: 100%; object-fit: cover; }
.kamera .bingkai { position: absolute; left: 50%; top: 45%; width: min(78vw, 58vh); aspect-ratio: 1; transform: translate(-50%, -50%); border: 3px solid rgba(255,255,255,.9); border-radius: 20px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); pointer-events: none; }
.kamera .kontrol { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: center; padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); }
.kamera .kontrol button { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; display: grid; place-items: center; }
.kamera .kontrol .jepret { width: 78px; height: 78px; background: #fff; box-shadow: 0 0 0 5px rgba(255,255,255,.35); }
.kamera .kontrol .ik { width: 28px; height: 28px; }

/* Onboarding */
.sambut { position: fixed; inset: 0; z-index: 60; background: var(--latar); display: grid; place-items: center; padding: 20px; overflow: auto; }
.sambut-kartu { width: min(100%, 560px); background: var(--permukaan); border-radius: 30px; box-shadow: var(--bayang-2); padding: 28px clamp(18px, 5vw, 36px); text-align: center; animation: naik .3s; }
.sambut-kartu .logo { width: 96px; height: 96px; border-radius: 26px; margin: 0 auto 12px; display: block; box-shadow: var(--bayang-2); }
.sambut-kartu h1 { font-family: var(--font-anak); font-size: 2rem; margin: 0 0 6px; line-height: 1.1; }
.sambut-kartu h2 { font-family: var(--font-anak); font-size: 1.6rem; margin: 0 0 6px; }
.sambut-kartu p { color: var(--tinta-2); line-height: 1.5; margin: 0 0 16px; }
.sambut-kartu .form { text-align: left; }
.langkah { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.langkah i { width: 28px; height: 6px; border-radius: 3px; background: var(--garis); }
.langkah i.aktif { background: var(--utama); }
.fitur { display: grid; gap: 10px; text-align: left; margin: 0 0 20px; }
.fitur div { display: flex; gap: 12px; align-items: center; background: var(--permukaan-2); border-radius: 14px; padding: 10px 12px; font-weight: 700; }
.fitur .emo { width: 34px; height: 34px; }
.ava-pilih { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.ava-pilih button { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--permukaan-2); }
.ava-pilih button .emo { width: 34px; height: 34px; }
.ava-pilih button[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--utama); background: var(--utama-muda); }
.warna-pilih { display: flex; flex-wrap: wrap; gap: 10px; }
.warna-pilih button { width: 40px; height: 40px; border-radius: 50%; background: var(--c); }
.warna-pilih button[aria-pressed="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--c); }
.tema-pilih { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.tema-pilih button { border: 2px solid var(--garis); border-radius: 14px; padding: 10px; background: var(--l); display: grid; gap: 8px; text-align: left; font-weight: 800; }
.tema-pilih button i { display: flex; gap: 4px; }
.tema-pilih button i b { width: 22px; height: 22px; border-radius: 50%; background: var(--c); }
.tema-pilih button[aria-pressed="true"] { border-color: var(--tinta); box-shadow: 0 0 0 2px var(--tinta); }

.catatan { font-size: .88rem; color: var(--tinta-2); line-height: 1.5; }
.info { display: flex; gap: 10px; align-items: flex-start; background: #FFF6DB; color: #6A4D00; border-radius: 14px; padding: 12px 14px; font-weight: 600; line-height: 1.45; margin-bottom: 14px; }
.info.biru { background: var(--utama-muda); color: var(--utama-2); }
.info.hijau { background: #E3F6EC; color: #165F3C; }
.info .ik { width: 22px; height: 22px; margin-top: 1px; }

/* Umum */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, calc(100% + 60px)); visibility: hidden; background: #1C2340; color: #fff; padding: 11px 20px; border-radius: 999px; font-weight: 700; z-index: 90; transition: transform .25s; max-width: calc(100vw - 32px); text-align: center; box-shadow: var(--bayang-2); pointer-events: none; }
.toast.tampil { transform: translate(-50%, 0); visibility: visible; }
.pesta { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.pesta span { position: absolute; width: 34px; height: 34px; animation: terbang 1.2s ease-out forwards; }
.pesta span .emo { width: 100%; height: 100%; }
.webview-lama { position: fixed; inset: 0; z-index: 200; background: #fff; display: grid; place-items: center; padding: 24px; text-align: center; font-family: sans-serif; color: #1C2340; }
.muat { position: fixed; inset: 0; z-index: 100; background: var(--latar); display: grid; place-items: center; transition: opacity .25s; }
.muat img { width: 88px; height: 88px; border-radius: 24px; box-shadow: var(--bayang-2); animation: denyut 1.2s ease-in-out infinite; }
.piala { text-align: center; }
.piala .besar { width: 120px; height: 120px; margin: 0 auto 8px; display: block; animation: menang 1s; }

/* ---------------- Responsif ---------------- */
@media (max-width: 760px) {
  :root { --celah: 8px; --tinggi-atas: 56px; }
  .layar { padding: 0 8px 8px; }
  .kalimat { grid-template-columns: minmax(0, 1fr); padding: 8px 10px 0; }
  .aksi { order: 3; padding-bottom: 10px; }
  .rel { order: 2; margin-top: -4px; }
  .aksi .tbl { flex: 1; height: 58px; min-width: 0; flex-direction: row; gap: 8px; font-size: 1rem; }
  .aksi .tbl .ik { width: 24px; height: 24px; }
  .tbl-bicara { flex: 1.6 !important; font-size: 1.15rem !important; }
  .loko { width: 70px; }
  .jalur { min-height: 94px; }
  .wagon { min-width: 70px; height: 80px; }
  .wagon .sym { height: 38px; } .wagon .sym .emo { width: 34px; height: 34px; }
  .segmen button { padding: 7px 12px; font-size: .98rem; }
  .panel { padding: 6px; border-radius: 18px; }
  .panel-kepala { display: none; }
  .tile { border-width: 2.5px; border-bottom-width: 5px; border-radius: calc(var(--r) * .75); }
}
@media (max-width: 440px) {
  .profil-teks { display: none; }
  .profil-btn { margin-right: auto; padding-right: 4px; }
  .segmen button span { display: none; }
  .segmen button { padding: 8px 14px; }
  .segmen button .ik { width: 24px; height: 24px; }
}
/* Ponsel mendatar: bilah kalimat dibuat ringkas agar papan tetap lega */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --tinggi-atas: 46px; --celah: 6px; }
  .bar-atas { padding: 2px 10px; }
  .ava { width: 34px; height: 34px; font-size: 20px; } .ava .emo { width: 24px; height: 24px; }
  .segmen { padding: 3px; } .segmen button { padding: 4px 12px; font-size: .95rem; }
  .gigi { width: 40px; height: 40px; } .gigi > span { width: 33px; height: 33px; }
  .kalimat { grid-template-columns: minmax(0, 1fr) auto; padding: 4px 10px 0; border-radius: 18px; }
  .aksi { order: 0; padding-bottom: 6px; gap: 6px; }
  .rel { order: 0; height: 10px; background-size: 100% 3px, 100% 7px; background-position: 0 1px, 0 4px; }
  .aksi .tbl { height: 50px; min-width: 60px; flex: 0 0 auto; flex-direction: column; font-size: .8rem; box-shadow: 0 3px 0 var(--bb); border-radius: 12px; }
  .aksi .tbl .ik { width: 22px; height: 22px; }
  .tbl-bicara { min-width: 96px !important; font-size: 1rem !important; }
  .jalur { min-height: 58px; gap: 8px; }
  .loko { width: 48px; }
  .wagon { height: 50px; min-width: 52px; font-size: .8rem; padding: 1px 7px; border-width: 2px; border-radius: 11px 11px 7px 7px; }
  .wagon::before, .wagon::after { width: 11px; height: 11px; bottom: -8px; box-shadow: inset 0 0 0 3px #39405E, inset 0 0 0 5px #9AA3C0; }
  .wagon .kait { left: -10px; width: 10px; bottom: 8px; }
  .wagon .sym { height: 24px; } .wagon .sym .emo { width: 22px; height: 22px; } .wagon .sym img.foto { width: 24px; height: 24px; border-radius: 5px; }
  .gerbong { padding: 2px 4px 9px; gap: 9px; }
  .kosong { font-size: 1rem; margin-bottom: 6px; }
  .panel-kepala { display: none; }
  .profil-teks small { display: none; }
  /* Tab kategori menjadi rel tegak di kiri */
  .area { grid-template-columns: 78px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: "tab papan"; }
  .tab-bar { flex-direction: column; overflow-x: hidden; overflow-y: auto; padding: 2px; gap: 6px; }
  .tab { flex-direction: column; gap: 1px; padding: 5px 2px; width: 100%; font-size: .72rem; line-height: 1.1; white-space: normal; text-align: center; border-radius: 12px; }
  .tab .emo { width: 26px; height: 26px; }
  .panel { padding: 4px; }
}

@keyframes masuk { from { transform: translateX(50px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ayun { from { transform: translateY(0); } to { transform: translateY(-5px); } }
@keyframes goyangLoko { from { transform: translateY(0); } to { transform: translateY(-3px); } }
@keyframes asap { 0% { opacity: .9; transform: translate(0, 0) scale(.6); } 100% { opacity: 0; transform: translate(-22px, -40px) scale(2); } }
@keyframes relJalan { to { background-position: 0 2px, -32px 6px; } }
@keyframes pantul { 0% { transform: scale(1); } 40% { transform: scale(.92); } 70% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes goyang { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes menang { 0% { transform: scale(1); } 30% { transform: scale(1.12) rotate(-3deg); } 60% { transform: scale(1.06) rotate(2deg); } 100% { transform: scale(1); } }
@keyframes petunjuk { 50% { transform: scale(1.06); box-shadow: 0 0 0 7px var(--kuning); } }
@keyframes denyut { 50% { transform: scale(1.12); } }
@keyframes terbang { from { transform: translate(0, 0) scale(.4); opacity: 1; } to { transform: translate(var(--x), var(--y)) scale(1.2) rotate(var(--r)); opacity: 0; } }
@keyframes muncul { from { opacity: 0; } }
@keyframes naik { from { transform: translateY(18px); opacity: 0; } }
@keyframes geserMasuk { from { transform: translateY(24px); opacity: 0; } }
@keyframes isi { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes kedip { to { visibility: hidden; } }

body.tenang *:not(.menahan), body.tenang *::before { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *:not(.menahan) { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; } }
