/* Gaya mengikuti william-lee.dev & Cek Dulu: kertas hangat, tinta gelap, judul serif, UI sans, label pixel.
   Font: belum di-host sendiri (file font belum ada) -> pakai cadangan sistem yang mirip. */
:root {
  --paper: #f1f0ec;
  --bubble: #fbfaf7;
  --ink: #1b1d20;
  --muted: #5f646b;
  --rule: #d3d1ca;
  --slate: #4d6074;
  --slate-soft: #dfe4e9;
  --kamu: #dfe4e9;
  --serius: #f5ead2;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --pixel: "Silkscreen", ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); line-height: 1.5; -webkit-font-smoothing: antialiased;
}
.wadah { max-width: 46rem; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; }
h1 { font-size: clamp(2.6rem, 11vw, 4.2rem); line-height: 1; letter-spacing: -0.04em; }
h2 { font-size: 1.8rem; line-height: 1.1; letter-spacing: -0.025em; margin: 0.4rem 0; }
.kecil { color: var(--muted); font-size: 0.85rem; margin: 0.4rem 0 1rem; }
.peringatan { color: #7a4a00; }
.label-pixel { font-family: var(--pixel); font-size: 0.65rem; letter-spacing: 1.5px; color: var(--slate); font-weight: 700; }

/* ------------------------------------------------ nav */
.nav { display: flex; align-items: center; justify-content: space-between; padding-top: 1.1rem; padding-bottom: 1.1rem; }
.logo {
  display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: 8px; border: 0;
  background: var(--ink); color: var(--paper); cursor: pointer;
  font-family: var(--serif); font-style: italic; font-size: 1.1rem; letter-spacing: -0.5px;
}
.logo-kecil { width: 2rem; height: 2rem; font-size: 0.95rem; flex: none; }

/* ------------------------------------------------ landing */
.hero { padding: 3rem 16px 3rem; }
.lead { font-family: var(--serif); font-size: 1.3rem; line-height: 1.45; margin: 1.2rem 0 1.6rem; max-width: 34rem; min-height: 5.7em; }
.gelembung {
  display: inline-block; font-family: var(--pixel); font-size: 0.65rem; font-weight: 700; letter-spacing: 1.5px;
  background: var(--bubble); border: 2px solid var(--ink); padding: 0.25rem 0.6rem; margin-bottom: 1rem; position: relative;
}
.gelembung::after {
  content: ""; position: absolute; left: 0.8rem; bottom: -8px; width: 8px; height: 8px; background: var(--bubble);
  border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(45deg);
}

/* ------------------------------------------------ tombol & form */
.tombol-baris { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0; }
.tombol {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
  min-height: 2.9rem; padding: 0.5rem 1.3rem; border-radius: 999px;
  font: 600 0.92rem/1.2 var(--sans); cursor: pointer; border: 1.5px solid var(--ink);
  transition: transform 0.12s ease, background 0.12s ease;
}
.tombol:active { transform: translateY(1px); }
.tombol-gelap { background: var(--ink); color: var(--paper); }
.tombol-gelap:hover { background: #33363b; }
.tombol-garis { background: transparent; color: var(--ink); border-color: var(--rule); }
.tombol-garis:hover { border-color: var(--ink); }
.tombol-kecil { min-height: 2.5rem; padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.tombol:disabled { opacity: 0.55; cursor: wait; }
.ikon { background: none; border: 0; font-size: 1.2rem; cursor: pointer; color: var(--ink); padding: 0.4rem 0.5rem; border-radius: 8px; }
.ikon:hover { background: var(--slate-soft); }

.field { display: block; font-size: 0.88rem; font-weight: 600; margin: 1rem 0; }
.field input, .field textarea, .field select, .kartu-teman input, .kartu-teman textarea, .kartu-teman select {
  display: block; width: 100%; margin-top: 0.35rem; font: 400 0.95rem/1.4 var(--sans); color: var(--ink);
  background: var(--bubble); border: 1.5px solid var(--rule); border-radius: 10px; padding: 0.6rem 0.75rem;
}
.field input:focus, .field textarea:focus, .kartu-teman input:focus, .kartu-teman textarea:focus, #input-chat:focus {
  outline: 2px solid var(--slate); outline-offset: 1px; border-color: var(--slate);
}
.saklar { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; cursor: pointer; margin: 0.4rem 0; }
.saklar input { width: 1.1rem; height: 1.1rem; accent-color: var(--ink); }

/* ------------------------------------------------ kartu teman */
.daftar-teman { display: grid; gap: 0.9rem; margin: 1rem 0; }
.kartu-teman {
  background: var(--bubble); border: 2px solid var(--ink); border-radius: var(--radius); padding: 0.9rem;
  display: grid; grid-template-columns: 4.5rem 1fr; gap: 0.4rem 0.9rem;
}
.kartu-teman .ava-kolom { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
.ava { width: 4.2rem; height: 4.2rem; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; background: var(--slate-soft); padding: 0; cursor: pointer; }
.ava svg { display: block; width: 100%; height: 100%; }
.kartu-teman .baris-atas { display: flex; gap: 0.5rem; align-items: center; }
.kartu-teman .baris-atas input { margin: 0; font-weight: 600; }
.kartu-teman label { font-size: 0.8rem; color: var(--muted); }
.kartu-teman textarea { resize: vertical; min-height: 2.4rem; }
.slider-grid { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 0.3rem 1rem; margin-top: 0.3rem; }
.slider-grid label { display: grid; grid-template-columns: 1fr auto; font-size: 0.78rem; color: var(--muted); }
.slider-grid input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--ink); }
.slider-grid output { font-family: var(--pixel); font-size: 0.7rem; color: var(--ink); }
.kartu-teman .lebar { grid-column: 1 / -1; }

@media (max-width: 480px) {
  .kartu-teman { grid-template-columns: 1fr; }
  .kartu-teman .ava-kolom { flex-direction: row; }
  .slider-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------ chat */
.layar-chat { display: flex; flex-direction: column; height: 100dvh; max-width: 46rem; margin: 0 auto; border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); }
.chat-kepala { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.8rem; background: var(--bubble); border-bottom: 2px solid var(--ink); }
.chat-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-info strong { font-family: var(--serif); font-size: 1.1rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-info .kecil { margin: 0; font-size: 0.75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progres { font-family: var(--pixel); font-size: 0.62rem; letter-spacing: 0.5px; color: var(--slate); white-space: nowrap; overflow-x: auto; }
.menu-wadah { position: relative; }
.menu { position: absolute; right: 0; top: 2.4rem; background: var(--bubble); border: 2px solid var(--ink); border-radius: 10px; z-index: 5; min-width: 11rem; overflow: hidden; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0.65rem 0.9rem; font: 0.9rem var(--sans); cursor: pointer; color: var(--ink); }
.menu button:hover { background: var(--slate-soft); }

.chat-isi { flex: 1; overflow-y: auto; padding: 1rem 0.8rem; display: flex; flex-direction: column; gap: 0.55rem; }
.chat-isi.serius { background: #f7f2e6; }
.msg { display: flex; gap: 0.5rem; align-items: flex-end; max-width: 85%; animation: muncul 0.25s ease-out both; }
.msg .ava { width: 2.1rem; height: 2.1rem; border-width: 1.5px; border-radius: 8px; flex: none; cursor: default; }
.balon { background: var(--bubble); border: 2px solid var(--ink); border-radius: 4px 14px 14px 14px; padding: 0.35rem 0.75rem 0.45rem; word-wrap: break-word; overflow-wrap: anywhere; }
.balon .nama { display: block; font-size: 0.75rem; font-weight: 700; margin-bottom: 0.05rem; }
.balon .teks { white-space: pre-wrap; font-size: 0.95rem; }
.msg.kamu { align-self: flex-end; }
.msg.kamu .balon { background: var(--kamu); border-radius: 14px 4px 14px 14px; }
.msg.sistem { align-self: center; max-width: 92%; }
.msg.sistem .balon { border: 1.5px dashed var(--rule); background: transparent; color: var(--muted); font-size: 0.82rem; border-radius: 10px; text-align: center; }
.mengetik { color: var(--muted); font-size: 0.82rem; font-style: italic; padding-left: 2.6rem; min-height: 1.2rem; }
.mengetik .titik::after { content: ""; animation: titik 1.2s steps(4) infinite; }
@keyframes titik { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
@keyframes muncul { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.chat-kaki { display: flex; gap: 0.4rem; padding: 0.6rem; border-top: 2px solid var(--ink); background: var(--bubble); align-items: center; flex-wrap: wrap; }
#input-chat { flex: 1 1 10rem; min-width: 0; font: 0.95rem var(--sans); padding: 0.65rem 0.8rem; border: 1.5px solid var(--rule); border-radius: 999px; background: var(--paper); color: var(--ink); }

.kartu-bantuan { margin: 0 0.8rem 0.6rem; background: var(--serius); border: 2px solid var(--ink); border-radius: var(--radius); padding: 0.9rem 1rem; font-size: 0.92rem; }
.kartu-bantuan p { margin: 0.4rem 0; }
.kartu-bantuan a { color: var(--ink); }

/* ------------------------------------------------ dokumen */
.dok-alat { padding-bottom: 0.5rem; }
.dokumen {
  max-width: 46rem; margin: 0 auto 3rem; background: #fff; border: 1px solid var(--rule);
  padding: 2.5rem clamp(16px, 6vw, 3.5rem); font-family: "Times New Roman", var(--serif); font-size: 1.05rem; line-height: 1.6;
}
.dokumen .sampul { text-align: center; margin-bottom: 2.5rem; }
.dokumen .sampul h1 { font-size: 1.9rem; letter-spacing: -0.01em; font-weight: 600; }
.dokumen .sampul p { white-space: pre-line; color: var(--muted); }
.dokumen h2 { font-size: 1.45rem; margin: 2rem 0 0.6rem; font-weight: 600; }
.dokumen h3, .dokumen h4 { font-size: 1.15rem; margin: 1.3rem 0 0.4rem; font-weight: 600; font-family: "Times New Roman", var(--serif); }
.dokumen p { margin: 0.5rem 0; text-align: justify; }
.dokumen .rumus { text-align: center; margin: 0.8rem 0; overflow-x: auto; }
.dokumen .catatan { font-family: var(--sans); font-style: italic; font-size: 0.8rem; color: var(--muted); border-left: 3px solid var(--rule); padding: 0.2rem 0.7rem; margin: 0.4rem 0 0.8rem; }
.dokumen .kaki-dok { margin-top: 3rem; text-align: center; font-family: var(--sans); font-size: 0.75rem; font-style: italic; color: var(--muted); }
.dokumen.tanpa-lucu .catatan, .dokumen.tanpa-lucu .kaki-dok { display: none; }
.dokumen table { border-collapse: collapse; margin: 0.6rem 0; }
.dokumen td { border: 1px solid var(--rule); padding: 0.2rem 0.5rem; }
.dokumen code { font-size: 0.9em; }
.dokumen .menunggu { color: var(--muted); font-style: italic; }

.toast { position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 0.6rem 1rem; border-radius: 10px; font-size: 0.88rem; z-index: 20; max-width: calc(100% - 32px); }

@media print {
  body { background: #fff; }
  .no-print, .toast, .layar:not(#layar-dok) { display: none !important; }
  .dokumen { border: 0; padding: 0; margin: 0; max-width: none; }
  .dokumen h2 { page-break-after: avoid; }
  .dokumen .sampul { page-break-after: always; }
}
