@font-face { font-family: 'Rajdhani'; font-weight: 700; font-display: swap; src: url('fonts/rajdhani-700.woff2') format('woff2'); }
@font-face { font-family: 'Share Tech Mono'; font-display: swap; src: url('fonts/share-tech-mono.woff2') format('woff2'); }

:root {
  color-scheme: light dark;
  --latar: #f3efe6;
  --muka: #fffdf8;
  --muka2: #ebe5d8;
  --dakwat: #1c2128;
  --dakwat2: #5f6670;
  --garis: #ddd5c4;
  --utama: #8f5c0f;
  --utama-latar: #a66d17;
  --utama-teks: #fffaf0;
  --bahaya: #b3261e;
  --ok: #2c7a4b;
  --d: #1f63b5;
  --s: #b3261e;
  --bayang: 0 1px 2px rgb(40 30 10 / 8%), 0 8px 24px rgb(40 30 10 / 6%);
  --jejari: 16px;
  --atas: env(safe-area-inset-top, 0px);
  --bawah: env(safe-area-inset-bottom, 0px);
  --mono: 'Share Tech Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --latar: #0d1115;
    --muka: #151b21;
    --muka2: #1d252d;
    --dakwat: #ece7dd;
    --dakwat2: #99a2ac;
    --garis: #28313a;
    --utama: #e3aa4c;
    --utama-latar: #e3aa4c;
    --utama-teks: #1d1405;
    --bahaya: #ff7a6e;
    --ok: #63c98e;
    --d: #7cb4ff;
    --s: #ff8a7f;
    --bayang: 0 1px 2px rgb(0 0 0 / 40%), 0 10px 30px rgb(0 0 0 / 35%);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--latar);
  color: var(--dakwat);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body.tirai #app, body.tirai dialog { visibility: hidden; }
#app { max-width: 640px; margin: 0 auto; padding: calc(var(--atas) + 8px) 16px calc(var(--bawah) + 96px); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
.mono { font-family: var(--mono); letter-spacing: .02em; }
.kecil { font-size: 13px; color: var(--dakwat2); }
.nota { color: var(--dakwat2); }
.ralat { color: var(--bahaya); font-size: 14px; }
.ralat:empty { display: none; }
.ikon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Butang ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border: 1px solid var(--garis); border-radius: 12px;
  background: var(--muka); color: var(--dakwat); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, .baris:focus-visible, .st-baris:focus-visible, .cip:focus-visible, .seg:focus-visible { outline: 2px solid var(--utama); outline-offset: 2px; }
.btn.utama { background: var(--utama-latar); border-color: transparent; color: var(--utama-teks); }
.btn.bahaya { background: var(--bahaya); border-color: transparent; color: #fff; }
.bahaya-teks { color: var(--bahaya) !important; }
.btn.besar { width: 100%; min-height: 52px; font-size: 17px; }
.btn.kecil { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.teks { border: 0; background: none; color: var(--utama); }
.btn.ikon-sahaja { width: 44px; padding: 0; border: 0; background: none; color: var(--dakwat2); }
.butang { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.butang .btn { flex: 1; }

/* ---------- Skrin tengah (log masuk, kunci) ---------- */
.tengah { display: flex; flex-direction: column; gap: 14px; max-width: 380px; margin: 8vh auto 0; text-align: center; }
.tengah.lebar { max-width: 440px; margin-top: 4vh; text-align: left; }
.tengah .ralat { text-align: center; }
.jenama { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 6px; }
.jenama h1 { font: 700 34px/1 'Rajdhani', sans-serif; letter-spacing: .32em; text-transform: uppercase; padding-left: .32em; }
/* Dail peti besi: tanda di sekeliling, logam di tengah. */
.dail {
  position: relative; display: grid; place-items: center; width: 96px; height: 96px; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, var(--muka) 0 52%, transparent 53%),
    repeating-conic-gradient(from -2deg, var(--utama) 0 4deg, transparent 4deg 30deg),
    radial-gradient(circle, var(--muka2) 0 70%, var(--garis) 71%);
  box-shadow: var(--bayang), inset 0 0 0 2px var(--garis);
  color: var(--utama);
}
.dail .ikon { width: 34px; height: 34px; stroke-width: 1.6; }
.dail.kecil { width: 64px; height: 64px; }
.dail.kecil .ikon { width: 24px; height: 24px; }
.amaran { padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--bahaya) 10%, var(--muka)); border: 1px solid color-mix(in srgb, var(--bahaya) 30%, transparent); font-size: 14px; }
.pusing { width: 32px; height: 32px; margin: 0 auto; border: 3px solid var(--garis); border-top-color: var(--utama); border-radius: 50%; animation: pusing .8s linear infinite; }
@keyframes pusing { to { transform: rotate(1turn); } }

/* ---------- Borang ---------- */
.medan { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; text-align: left; }
.label, .label-luar { font-size: 13px; font-weight: 600; color: var(--dakwat2); }
.label-luar { margin-top: 16px; }
input, textarea, select {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--garis); border-radius: 12px;
  background: var(--muka); color: var(--dakwat); font: inherit; font-size: 16px;
}
textarea { resize: vertical; min-height: 96px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--utama); outline-offset: -1px; border-color: transparent; }
input.rahsia { font-family: var(--mono); letter-spacing: .04em; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--utama-latar); }
input[type=range] { padding: 0; min-height: 32px; border: 0; background: none; accent-color: var(--utama-latar); }
.input-btn { display: flex; align-items: center; border: 1px solid var(--garis); border-radius: 12px; background: var(--muka); }
.input-btn:focus-within { outline: 2px solid var(--utama); outline-offset: -1px; border-color: transparent; }
.input-btn input { border: 0; background: none; outline: none; min-width: 0; }
.tanda { display: flex; align-items: center; gap: 10px; margin-top: 14px; text-align: left; font-size: 15px; cursor: pointer; }
.tanda.kecil { margin: 0; font-size: 13px; color: var(--dakwat2); gap: 6px; }
.meter { height: 4px; margin-top: 6px; border-radius: 4px; background: var(--muka2); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; border-radius: inherit; transition: width .2s, background .2s; }
.meter[data-tahap="1"] span { width: 25%; background: var(--bahaya); }
.meter[data-tahap="2"] span { width: 50%; background: #d08a1a; }
.meter[data-tahap="3"] span { width: 75%; background: #6aa84f; }
.meter[data-tahap="4"] span { width: 100%; background: var(--ok); }
.segmen { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 4px; border-radius: 14px; background: var(--muka2); }
.seg { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; padding: 6px 2px; border: 0; border-radius: 10px; background: none; color: var(--dakwat2); font: 600 12px/1.2 inherit; font-family: inherit; cursor: pointer; }
.seg[aria-pressed="true"] { background: var(--muka); color: var(--utama); box-shadow: var(--bayang); }
.penjana { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--muka2); }
.pratonton { padding: 10px 12px; border-radius: 10px; background: var(--muka); font-size: 18px; word-break: break-all; min-height: 46px; }
.julat { display: flex; flex-direction: column; margin-top: 8px; font-size: 14px; }
.pilihan { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.pilihan .tanda { margin-top: 6px; font-size: 14px; }
.medan-tambahan { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.baris-medan { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 10px; border-radius: 12px; background: var(--muka2); }
.baris-medan > input, .baris-medan > .input-btn { grid-column: 1 / -1; }
.baris-medan > .btn { justify-self: end; }

/* ---------- Senarai ---------- */
.atas { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 4px; margin: 0 -16px; padding: calc(var(--atas) + 6px) 8px 6px 16px;
  background: color-mix(in srgb, var(--latar) 85%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
#app > .atas { margin-top: calc(-8px - var(--atas)); }
.atas h1 { flex: 1; font: 700 24px/1 'Rajdhani', sans-serif; letter-spacing: .22em; text-transform: uppercase; }
.cip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 1px solid var(--garis); border-radius: 999px;
  background: var(--muka); color: var(--dakwat2); font: 600 13px/1 inherit; font-family: inherit; white-space: nowrap; cursor: pointer; }
.cip .ikon { width: 16px; height: 16px; }
.cip.ok { color: var(--ok); }
.cip.ralat { color: var(--bahaya); }
.cip.sibuk .ikon { animation: denyut 1s ease-in-out infinite alternate; }
@keyframes denyut { to { opacity: .3; } }
.cip[aria-pressed="true"] { background: var(--dakwat); color: var(--latar); border-color: transparent; }
.cari { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 0 12px; border-radius: 12px; background: var(--muka2); color: var(--dakwat2); }
.cari input { border: 0; background: none; padding-left: 0; }
.cari input:focus { outline: none; }
.cip-baris { display: flex; gap: 8px; margin: 12px -16px 0; padding: 0 16px 2px; overflow-x: auto; scrollbar-width: none; }
.cip-baris::-webkit-scrollbar { display: none; }
.cip-baris:empty { display: none; }
.senarai { list-style: none; margin: 14px 0 0; padding: 0; border-radius: var(--jejari); background: var(--muka); box-shadow: var(--bayang); overflow: hidden; }
.senarai li + li { border-top: 1px solid var(--garis); }
.baris { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 14px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.baris:active { background: var(--muka2); }
.baris.statik { cursor: default; }
.baris .teks { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.baris b, .baris small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.baris small { color: var(--dakwat2); font-size: 14px; }
.jubin { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--muka2); color: var(--utama); }
.jubin.server { color: var(--d); }
.jubin.wifi { color: var(--ok); }
.jubin.nota { color: var(--dakwat2); }
.bintang { color: var(--utama); }
.bintang .ikon { width: 18px; height: 18px; fill: currentColor; }
.titik { width: 8px; height: 8px; border-radius: 50%; background: var(--bahaya); flex: none; }
.kosong { margin-top: 12vh; text-align: center; color: var(--dakwat2); display: flex; flex-direction: column; align-items: center; gap: 8px; }
p.kosong { display: block; margin-top: 32px; }
.fab { position: fixed; right: max(20px, calc(50vw - 300px)); bottom: calc(var(--bawah) + 24px); z-index: 6; display: grid; place-items: center;
  width: 60px; height: 60px; border: 0; border-radius: 20px; background: var(--utama-latar); color: var(--utama-teks); box-shadow: var(--bayang); cursor: pointer; }
.fab .ikon { width: 28px; height: 28px; stroke-width: 2.2; }

/* ---------- Helaian ---------- */
dialog:focus { outline: none; }
dialog.helaian {
  width: 100%; max-width: 640px; max-height: 92dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: 22px 22px 0 0;
  background: var(--latar); color: var(--dakwat); box-shadow: var(--bayang); overflow: hidden; display: flex; flex-direction: column;
}
dialog.helaian:not([open]) { display: none; }
dialog.helaian[open] { animation: naik .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes naik { from { transform: translateY(40px); opacity: 0; } }
dialog::backdrop { background: rgb(0 0 0 / 45%); }
@media (min-width: 700px) {
  dialog.helaian { margin: auto; border-radius: 22px; max-height: 86dvh; }
  dialog.helaian.kecil { max-width: 440px; }
}
.d-atas { display: flex; align-items: center; gap: 8px; padding: 14px 8px 8px 20px; }
.d-atas h2 { flex: 1; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-isi { padding: 4px 16px calc(var(--bawah) + 20px); overflow-y: auto; overscroll-behavior: contain; }
.d-isi h3 { margin: 18px 4px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--dakwat2); }
.d-isi h3:first-child { margin-top: 4px; }
.kad { margin-top: 10px; border-radius: var(--jejari); background: var(--muka); box-shadow: var(--bayang); overflow: hidden; }
.kad:first-child { margin-top: 0; }
.kad > * + * { border-top: 1px solid var(--garis); }
.f-baris { display: flex; align-items: center; gap: 2px; padding: 8px 4px 8px 16px; min-height: 60px; }
.f-teks { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 4px 0; }
.kad > .f-teks { padding: 12px 16px; }
.nilai { overflow-wrap: anywhere; font-size: 17px; }
.nilai.mono { font-size: 18px; }
.nilai .d, .pratonton .d { color: var(--d); }
.nilai .s, .pratonton .s { color: var(--s); }
.nota-isi { white-space: pre-wrap; overflow-wrap: anywhere; }
.kad > .btn.kecil { margin: 0 12px 12px; border-top: 1px solid var(--garis); }
.sejarah summary { display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer; color: var(--dakwat2); font-weight: 600; list-style: none; }
.sejarah summary::-webkit-details-marker { display: none; }
.meta { margin: 14px 4px 0; }
.st-baris { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 10px 14px 10px 16px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.st-baris > .ikon:first-child { color: var(--utama); }
.st-baris > .ikon:last-child { width: 18px; height: 18px; color: var(--dakwat2); }
.st-baris .teks { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.st-baris small { color: var(--dakwat2); font-size: 13px; }
.st-baris.statik { cursor: default; }
.st-baris select { width: auto; min-height: 38px; }
.st-baris.bahaya-teks > .ikon:first-child { color: var(--bahaya); }

/* ---------- Roti ---------- */
.roti { position: fixed; inset: auto auto calc(var(--bawah) + 100px) 50%; margin: 0; border: 0; z-index: 50; overflow: visible; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--dakwat); color: var(--latar); font-size: 15px; box-shadow: var(--bayang); transform: translate(-50%, 20px); opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s; }
.roti.ada { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
