:root {
  --navy: #12355b;
  --navy-2: #0c2744;
  --gold: #f2b705;
  --red: #b3261e;
  --ink: #1d232b;
  --muted: #5f6b7a;
  --line: #e2e6ec;
  --bg: #f5f7fa;
  --card: #ffffff;
  --chip: #eef3f9;
  --ex: #f9fafc;
  --radius: 10px;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); color: var(--ink); background: var(--bg); line-height: 1.55; font-size: 16px; }
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main:focus { outline: none; }

/* ---------- Header ---------- */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 58px; gap: 16px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: #fff; }
.logo:hover { text-decoration: none; }
.logo-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--gold); color: var(--navy); display: grid; place-items: center; font: 700 20px/1 var(--serif); }
.logo-text { font: 600 21px/1 var(--serif); letter-spacing: .2px; }
.logo-text b { color: var(--gold); font-weight: 700; }
.logo-text small { font: 500 13px var(--sans); opacity: .7; margin-left: 1px; }
.topnav { display: flex; gap: 22px; }
.topnav a { color: #dbe6f3; font-size: 14px; font-weight: 500; }
.topnav a:hover { color: #fff; }

.searchbar { background: var(--navy-2); padding: 12px 0; }
.search { display: flex; gap: 8px; align-items: stretch; }
.search-field { position: relative; flex: 1; min-width: 0; }
.search-field input { width: 100%; height: 46px; border: 0; border-radius: 8px; padding: 0 16px; font: 500 17px var(--sans); color: var(--ink); background: #fff; outline: none; }
.search-field input:focus { box-shadow: 0 0 0 3px rgba(242,183,5,.6); }
.search-btn { width: 52px; border: 0; border-radius: 8px; background: var(--gold); color: var(--navy); cursor: pointer; display: grid; place-items: center; }
.search-btn:hover { filter: brightness(1.05); }

.suggest { position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px 0; list-style: none; background: #fff; color: var(--ink); border-radius: 8px; box-shadow: 0 10px 30px rgba(12,39,68,.25); z-index: 30; max-height: 360px; overflow-y: auto; }
.suggest li { padding: 9px 16px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.suggest li.active, .suggest li:hover { background: var(--chip); }
.suggest .s-word { font-weight: 600; }
.suggest .s-word mark { background: none; color: var(--red); }
.suggest .s-lang { font: 600 10px var(--sans); letter-spacing: .04em; color: var(--muted); border: 1px solid currentColor; border-radius: 4px; padding: 1px 4px; margin-left: -4px; margin-right: auto; flex-shrink: 0; opacity: .8; align-self: center; }
.suggest .s-meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Layout ---------- */
main { padding-top: 28px; padding-bottom: 48px; min-height: 60vh; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; }
.side .card { padding: 18px 20px; margin-bottom: 18px; }
.side h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a { display: block; padding: 5px 0; }
.side li a.current { font-weight: 700; color: var(--red); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); }

/* ---------- Entry ---------- */
.entry + .entry { margin-top: 20px; }
.entry-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; padding-bottom: 14px; border-bottom: 2px solid var(--line); }
.headword { font: 700 40px/1.1 var(--serif); color: var(--red); margin: 0; letter-spacing: -.3px; }
.headword sup { font-size: 18px; color: var(--muted); margin-left: 2px; }
.pron { color: var(--muted); font-size: 17px; }
.audio { border: 1px solid var(--line); background: var(--chip); color: var(--navy); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: inline-grid; place-items: center; align-self: center; }
.audio:hover { background: var(--navy); color: #fff; }
.pos { font-style: italic; color: var(--navy); font-weight: 600; }
.freq { display: inline-flex; gap: 3px; align-items: center; align-self: center; font-size: 12px; color: var(--muted); }
.freq i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: inline-block; }
.freq i.on { background: var(--gold); }
.freq span { margin-left: 4px; }

.senses { list-style: none; counter-reset: s; margin: 18px 0 0; padding: 0; }
.sense { counter-increment: s; position: relative; padding: 0 0 18px 38px; }
.senses.multi .sense::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; font: 700 13px/26px var(--sans); text-align: center; }
.senses:not(.multi) .sense { padding-left: 0; }
.signpost { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .06em; background: var(--gold); color: var(--navy); padding: 1px 8px; border-radius: 4px; margin-right: 6px; vertical-align: 2px; }
.label { font-style: italic; color: var(--muted); font-size: 14px; margin-right: 6px; }
.def { color: var(--ink); }
.trans { display: block; font-weight: 700; font-size: 19px; color: var(--navy); margin-top: 3px; }
.examples { list-style: none; margin: 8px 0 0; padding: 0; }
.examples li { background: var(--ex); border-left: 3px solid #c9d5e4; padding: 7px 12px; margin-top: 6px; border-radius: 0 6px 6px 0; }
.examples .ex { font-style: italic; }
.examples .ex-t { display: block; color: var(--muted); font-size: 14px; }

.note { background: #fff8e1; border: 1px solid #f3dc8c; border-radius: 8px; padding: 12px 16px; margin: 4px 0 18px; font-size: 15px; }
.note b { color: #7a5a00; }

.box { border: 1px solid var(--line); border-radius: 8px; margin-top: 16px; overflow: hidden; }
.box h4 { margin: 0; padding: 9px 16px; background: var(--chip); color: var(--navy); font-size: 13px; text-transform: uppercase; letter-spacing: .07em; }
.box .box-body { padding: 10px 16px; }
.phrases { list-style: none; margin: 0; padding: 0; }
.phrases li { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.phrases li:last-child { border-bottom: 0; }
.phrases b { color: var(--ink); }
.phrases span { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-block; background: var(--chip); border: 1px solid #d9e3ef; color: var(--navy); padding: 4px 12px; border-radius: 999px; font-size: 14px; }
a.chip:hover { background: var(--navy); color: #fff; text-decoration: none; }
.chip.plain { cursor: default; }
.rel-row { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; flex-wrap: wrap; }
.rel-row .k { font-size: 13px; font-weight: 700; color: var(--muted); min-width: 70px; }

.entry-actions { display: flex; gap: 8px; margin-top: 18px; }
.btn { border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 6px; font: 500 14px var(--sans); color: var(--navy); cursor: pointer; }
.btn:hover { border-color: var(--navy); }

/* ---------- Kamus sumber ---------- */
.srcBox { margin-top: 20px; }
.clash { background: var(--chip); border: 1px solid #d9e3ef; border-left: 4px solid var(--gold); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 15px; }
.clash a { font-weight: 600; white-space: nowrap; }
.lang-head { font: 700 14px var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.lang-head:first-of-type { margin-top: 0; }
.card.src { margin-bottom: 16px; padding: 18px 24px; }
.src-name { margin: 0 0 10px; font: 700 15px var(--sans); color: #fff; background: var(--navy); display: inline-block; padding: 4px 12px; border-radius: 6px; letter-spacing: .02em; }
.src-entry { border-top: 1px solid var(--line); padding: 10px 0 6px; position: relative; }
.src-entry:first-of-type { border-top: 0; }
.src-entry p { margin: 0; line-height: 1.65; }
.src-head { color: var(--red); font-family: var(--serif); font-size: 1.15em; }
.src-pos { color: var(--navy); font-weight: 600; }
.src-num { display: inline-block; min-width: 18px; font-weight: 700; color: var(--navy); }
.src-page { display: block; text-align: right; font-size: 12px; color: var(--muted); }
.src-k { min-width: 150px; }
.src-note { display: inline-block; margin-top: 4px; font-size: 12px; color: #7a5a00; background: #fff8e1; border: 1px solid #f3dc8c; border-radius: 4px; padding: 1px 8px; }
.src-title { margin: 0 0 4px; }
.src-entry { padding: 16px 0 8px; }
.src-entry + .src-entry { border-top: 2px solid var(--line); margin-top: 8px; }
.src-hw { font-size: 34px; }
.src-entry .box { margin-top: 6px; }
.src-entry .label { font-style: italic; color: var(--muted); margin-right: 6px; }
.signpost.sm { font-size: 10.5px; padding: 0 6px; vertical-align: 1px; }
.subsenses { list-style: none; margin: 8px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.subsenses li { padding: 4px 0 8px; }
.subsenses .trans { display: inline; font-size: 17px; }
.subsenses .def { margin-right: 6px; }
.sub-letter { font-weight: 700; color: var(--navy); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (max-width: 640px) { .src-hw { font-size: 28px; } .card.src { padding: 16px; } }

/* ---------- Home ---------- */
.hero { text-align: center; padding: 26px 0 30px; }
.hero h1 { font: 700 38px/1.2 var(--serif); margin: 0 0 10px; color: var(--navy); }
.hero p { color: var(--muted); margin: 0 auto; max-width: 600px; font-size: 17px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.wotd { background: linear-gradient(135deg, var(--navy), #1d4f84); color: #fff; border: 0; }
.wotd .tag { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--gold); font-weight: 700; }
.wotd h2 { font: 700 34px/1.1 var(--serif); margin: 8px 0 4px; }
.wotd h2 a { color: #fff; }
.wotd .pron { color: #b9cce2; }
.wotd .trans { color: var(--gold); }
.wotd .def { color: #e4ecf5; }
.card h3 { margin: 0 0 12px; font-size: 15px; color: var(--navy); }
.az { display: flex; flex-wrap: wrap; gap: 6px; }
.az a { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 6px; background: var(--chip); font-weight: 600; font-size: 14px; }
.az a:hover, .az a.current { background: var(--navy); color: #fff; text-decoration: none; }
.az a.empty { opacity: .35; pointer-events: none; }
.section-title { font: 700 22px var(--serif); color: var(--navy); margin: 34px 0 14px; }
.stats { display: flex; gap: 28px; justify-content: center; margin-top: 18px; color: var(--muted); font-size: 14px; }
.stats b { display: block; font: 700 26px var(--serif); color: var(--navy); }

/* ---------- List / Not found ---------- */
.wordlist { columns: 3; column-gap: 24px; list-style: none; padding: 0; margin: 16px 0 0; }
.wordlist li { break-inside: avoid; padding: 6px 0; border-bottom: 1px solid var(--line); }
.wordlist small { color: var(--muted); margin-left: 6px; }
.notfound h1 { font: 700 28px var(--serif); margin: 0 0 6px; }
.prose h1 { font: 700 30px var(--serif); color: var(--navy); margin-top: 0; }
.prose h2 { font: 700 20px var(--serif); color: var(--navy); margin-top: 28px; }
.muted { color: var(--muted); }

/* ---------- Footer ---------- */
.footer { background: var(--navy-2); color: #b9cce2; padding: 30px 0; font-size: 14px; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; align-items: flex-start; }
.footer p { margin: 8px 0 0; }
.footer-links { display: flex; flex-direction: column; gap: 6px; }
.footer-links a { color: #dbe6f3; }
.logo.small .logo-mark { width: 26px; height: 26px; font-size: 15px; }
.logo.small .logo-text { font-size: 17px; }
.copy { width: 100%; border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .wordlist { columns: 2; }
}
@media (max-width: 640px) {
  .topnav { display: none; }
  .card { padding: 18px 16px; }
  .headword { font-size: 32px; }
  .hero h1 { font-size: 28px; }
  .wordlist { columns: 1; }
  .stats { gap: 18px; }
}

/* ---------- Halaman kata BM: tab Makna / En ---------- */
.word-head { margin-bottom: 16px; padding-bottom: 0; }
.tabs { display: flex; gap: 4px; margin-top: 14px; border-bottom: 0; }
.tab { font: 600 15px var(--sans); color: var(--muted); background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 18px; cursor: pointer; }
.tab[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--gold); }
.tab:hover:not([disabled]) { color: var(--navy); }
.tab[disabled] { opacity: .4; cursor: default; }
.tab-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 28px; }
.tab-panel[hidden] { display: none; }
.mono-h { margin: 0 0 10px; font: 700 13px var(--sans); text-transform: uppercase; letter-spacing: .07em; color: var(--navy); }
.mono-h.sub { margin-top: 22px; }
.mono-block { padding: 12px 0; }
.mono-block + .mono-block { border-top: 1px solid var(--line); }
.mono-block .senses { margin-top: 8px; }
.src-tag { display: inline-block; font: 600 11px var(--sans); color: var(--navy); background: var(--chip); border: 1px solid #d9e3ef; border-radius: 4px; padding: 1px 7px; vertical-align: middle; letter-spacing: .02em; }
.phrases .src-tag { margin-left: 4px; opacity: .85; }
.en-list { line-height: 1.7; }
.src-detail { border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; }
.src-detail > summary { cursor: pointer; padding: 10px 16px; font-weight: 600; color: var(--navy); background: var(--ex); border-radius: 8px; }
.src-detail[open] > summary { border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.src-detail > .src-entry, .src-detail > .entry.inner { padding: 12px 16px; }
.entry.inner .headword { font-size: 26px; }
@media (max-width: 640px) { .tab-panel { padding: 16px; } .tab { padding: 10px 14px; } }

/* ---------- Laman utama Melayu Agung ---------- */
.hero.landing h1 { font-size: 44px; }
.land-card { display: block; color: inherit; text-decoration: none; border-top: 4px solid var(--gold); }
.land-card:hover { border-color: var(--gold); box-shadow: 0 4px 16px rgba(18, 53, 91, .08); }
.land-card h2 { margin: 6px 0 8px; font-family: var(--serif); color: var(--navy); }
.land-card .btn { margin-top: 8px; }
