:root {
  --bg: oklch(97.4% 0.009 165);
  --surface: oklch(99.3% 0.004 165);
  --ink: oklch(23% 0.022 165);
  --muted: oklch(44% 0.02 165);
  --line: oklch(86% 0.014 165);
  --brand: oklch(41% 0.085 165);
  --brand-press: oklch(35% 0.08 165);
  --brand-ink: oklch(98.6% 0.006 165);
  --brand-soft: oklch(93.5% 0.032 165);
  --wait: oklch(47% 0.1 70);
  --wait-soft: oklch(95% 0.035 85);
  --bad: oklch(49% 0.15 28);
  --bad-soft: oklch(95.5% 0.025 28);
  --ring: oklch(55% 0.13 165);
  --r: 12px;
  --tap: 52px;
  font-size: 17px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; flex: none; }

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.judul { font-size: 1rem; white-space: nowrap; margin-right: auto; }
.judul b { color: var(--brand); }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 40px; max-width: 52vw;
  padding: 4px 12px 4px 8px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 0.85rem; font-weight: 600;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip svg { width: 18px; height: 18px; }
.ikon {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
}

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.layar {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  width: 100%; max-width: 560px; margin: 0 auto;
}
.isi { flex: 1; padding: 16px; overflow-y: auto; }
h1 { font-size: 1.35rem; line-height: 1.25; margin: 4px 0 2px; }
h2 { font-size: 0.95rem; margin: 24px 0 8px; color: var(--brand); }
.sub { margin: 0 0 16px; color: var(--muted); }

.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 0.85rem; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-height: var(--tap);
  padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface);
  font-size: 1.05rem;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.4; }
select { appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--ring); }

.baris { display: flex; gap: 8px; align-items: stretch; margin: 0 0 12px; }
.baris input { flex: 1; }

.cek { display: flex; gap: 12px; align-items: center; min-height: 44px; margin: 0 0 4px; }
.cek input { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }

.segmen {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  margin: 0 0 16px; padding: 4px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface);
}
.segmen label { position: relative; }
.segmen input { position: absolute; opacity: 0; inset: 0; }
.segmen span {
  display: grid; place-items: center; min-height: 44px; padding: 4px 8px; text-align: center;
  border-radius: 9px; font-weight: 600; font-size: 0.95rem; color: var(--muted);
}
.segmen input:checked + span { background: var(--brand); color: var(--brand-ink); }
.segmen input:focus-visible + span { outline: 3px solid var(--ring); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px;
  border-radius: var(--r); border: 1px solid transparent;
  font-weight: 650; font-size: 1rem; cursor: pointer;
  transition: transform 120ms cubic-bezier(0.16, 1, 0.3, 1), background-color 120ms;
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn.utama { background: var(--brand); color: var(--brand-ink); }
.btn.utama:active { background: var(--brand-press); }
.btn.kedua { background: var(--surface); color: var(--brand); border-color: var(--line); }
.btn.teks { background: transparent; color: var(--muted); padding-inline: 12px; }
.btn.besar { width: 100%; min-height: 60px; font-size: 1.1rem; }
.btn.besar svg { width: 26px; height: 26px; }

.aksi {
  display: flex; gap: 8px;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  border-top: 1px solid var(--line); background: var(--surface);
}
.aksi.tiga .btn.utama { flex: 1; }

.catatan { font-size: 0.9rem; color: var(--muted); margin: 4px 0 12px; }
.catatan.kecil { font-size: 0.8rem; }
.error { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 10px; font-size: 0.95rem; margin: 0 0 12px; }
code { font-size: 0.85rem; background: var(--brand-soft); padding: 2px 6px; border-radius: 6px; word-break: break-all; }

.tip { background: var(--brand-soft); border-radius: var(--r); padding: 12px 14px 4px; margin: 0 0 16px; font-size: 0.95rem; }
.tip p { margin: 0 0 4px; }
.tip .btn { min-height: 40px; padding-inline: 0; color: var(--brand); }

.status {
  display: flex; gap: 8px; align-items: flex-start;
  border-radius: 10px; padding: 10px 12px; margin: 4px 0 0; font-size: 0.95rem;
  background: var(--brand-soft); color: var(--brand);
}
.status:empty { display: none; }
.status.tunggu { background: var(--wait-soft); color: var(--wait); }
.status.salah { background: var(--bad-soft); color: var(--bad); }
.status .btn { min-height: 36px; padding: 2px 10px; margin-left: auto; font-size: 0.9rem; white-space: nowrap; flex: none; }

.label-daftar { margin-top: 20px; color: var(--muted); font-size: 0.85rem; }
.riwayat { list-style: none; margin: 0; padding: 0; }
.riwayat li {
  display: flex; gap: 8px; align-items: baseline; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem;
}
.riwayat .nama { overflow-wrap: anywhere; min-width: 0; }
.riwayat .tanda { flex: none; font-size: 0.8rem; font-weight: 650; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.tanda.ok { background: var(--brand-soft); color: var(--brand); }
.tanda.tunggu { background: var(--wait-soft); color: var(--wait); }
.tanda.salah { background: var(--bad-soft); color: var(--bad); }
.tanda.hp { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }

.pratinjau { flex: 1; min-height: 120px; position: relative; background: oklch(25% 0.015 165); }
.pratinjau img { position: absolute; inset: 8px; width: calc(100% - 16px); height: calc(100% - 16px); object-fit: contain; display: block; }
.namafile { margin: 0; padding: 8px 16px; font-size: 0.85rem; color: var(--muted); overflow-wrap: anywhere; background: var(--surface); }

.sibuk {
  position: fixed; inset: 0; z-index: 20; display: grid; place-content: center; justify-items: center; gap: 12px;
  background: oklch(97.4% 0.009 165 / 0.92); color: var(--brand); font-weight: 600;
}
.putar { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--brand-soft); border-top-color: var(--brand); animation: putar 0.9s linear infinite; }
@keyframes putar { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 12px; right: 12px; z-index: 30;
  bottom: calc(env(safe-area-inset-bottom) + 96px);
  max-width: 536px; margin: 0 auto;
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--r);
  background: var(--ink); color: var(--surface); font-size: 0.95rem;
  animation: muncul 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
.toast .btn { min-height: 40px; padding: 4px 12px; background: var(--surface); color: var(--ink); margin-left: auto; }
@keyframes muncul { from { opacity: 0; transform: translateY(8px); } }

.tersembunyi { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; overflow: hidden; }

/* Layar pendek (landscape, panel kecil): rapatkan */
@media (max-height: 520px) {
  :root { --tap: 46px; }
  .isi { padding: 10px 16px; }
  .field { margin-bottom: 8px; }
  h1 { font-size: 1.15rem; }
  .btn.besar { min-height: 50px; }
  .aksi { padding-top: 8px; padding-bottom: calc(env(safe-area-inset-bottom) + 8px); }
  .toast { bottom: calc(env(safe-area-inset-bottom) + 72px); }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .toast { transition: none; animation: none; }
}
