:root {
  --emerald-950: #051D16;
  --emerald-900: #0A3025;
  --emerald-800: #134839;
  --gold-500: #C2963B;
  --gold-400: #E3C26F;
  --gold-200: #F8EAC4;
  --paper: #F8F5EE;
  --surface: #FFFFFF;
  --surface-alt: #FAF7F0;
  --ink: #16211D;
  --ink-soft: #54645D;
  --border: rgba(10, 48, 37, 0.11);
  --border-gold: rgba(194, 150, 59, 0.34);
  --shadow-sm: 0 2px 8px rgba(5, 29, 22, 0.04);
  --shadow-md: 0 12px 30px rgba(5, 29, 22, 0.07);
  --ok: #157347;
  --warn: #A8600B;
  --err: #B42318;
  --radius: 14px;
}
body.dark {
  --paper: #08110E;
  --surface: #0E1B17;
  --surface-alt: #13241E;
  --ink: #F2EFE7;
  --ink-soft: #9BB0A7;
  --border: rgba(227, 194, 111, 0.14);
  --border-gold: rgba(227, 194, 111, 0.28);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.45);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.015em;
  margin: 0 0 10px;
}
h1 { font-size: clamp(2.1rem, 4vw, 3.15rem); color: #FBF7EC; }
h2 { font-size: clamp(1.55rem, 2.3vw, 1.95rem); color: var(--emerald-900); }
body.dark h2 { color: var(--gold-400); }
h3 { font-size: 1.26rem; }
h4 { font-size: 1.06rem; }
.mono { font-family: 'JetBrains Mono', monospace; font-size: 0.84rem; }
.arabic { font-family: 'Amiri', serif; font-size: 1.32rem; color: var(--gold-500); }
.muted { color: var(--ink-soft); font-size: 0.93rem; }

.topbar {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(5, 29, 22, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(227, 194, 111, 0.28);
  padding: 12px 24px;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
}
.brand-lockup { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.brand-crest {
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--gold-400);
  background: var(--emerald-900);
  display: grid; place-items: center;
  font-family: 'Cinzel', serif; font-size: 1.05rem; font-weight: 700; color: var(--gold-200);
}
.brand-name {
  font-family: 'Cinzel', serif; font-size: 1.38rem; font-weight: 700; letter-spacing: 0.1em; line-height: 1.05;
  color: var(--gold-400);
  background: linear-gradient(135deg, #FFF6D9 0%, #E3C26F 55%, #BC8A2B 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.brand-sub { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.16em; color: rgba(248, 234, 196, 0.72); }
.nav-tabs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tab-btn {
  border: 1px solid transparent; background: transparent;
  color: rgba(248, 245, 238, 0.80); padding: 7px 13px; border-radius: 999px;
  cursor: pointer; font-family: inherit; font-size: 0.84rem; font-weight: 500; transition: all 0.18s ease;
}
.tab-btn:hover { color: #FFFFFF; background: rgba(255, 255, 255, 0.07); }
.tab-btn.active { background: var(--gold-400); color: var(--emerald-950); font-weight: 700; }

.hero {
  background: linear-gradient(155deg, var(--emerald-950) 0%, var(--emerald-900) 100%);
  color: #F8F5EE; padding: 48px 24px 40px; border-bottom: 1px solid var(--border-gold);
}
.hero-inner { max-width: 1180px; margin: 0 auto; }
.eyebrow {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  border: 1px solid rgba(227, 194, 111, 0.36); color: var(--gold-200);
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 14px;
}
.hero p.lead { max-width: 680px; color: rgba(248, 245, 238, 0.84); font-size: 1.02rem; margin: 0 0 28px; }
.hero-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat-box {
  text-align: left; width: 100%; font-family: inherit; color: inherit;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(227, 194, 111, 0.22);
  border-radius: 12px; padding: 15px 16px; cursor: pointer; transition: all 0.2s ease;
}
.stat-box:hover { transform: translateY(-2px); border-color: var(--gold-400); background: rgba(227, 194, 111, 0.10); }
.stat-num { font-family: 'Fraunces', serif; font-size: 1.65rem; font-weight: 600; color: var(--gold-200); line-height: 1.1; }
.stat-lbl { font-size: 0.8rem; color: rgba(248, 245, 238, 0.76); margin-top: 4px; }

.container { max-width: 1180px; margin: 0 auto; padding: 36px 24px 80px; }
.panel { display: none; animation: fadeIn 0.22s ease; }
.panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.section-head { margin-bottom: 22px; }
.section-head p { margin: 0; max-width: 720px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 26px; margin-bottom: 22px; box-shadow: var(--shadow-sm);
}
.card-elevated { box-shadow: var(--shadow-md); border-color: var(--border-gold); }
.split-map { display: grid; grid-template-columns: 1.45fr 1fr; gap: 22px; align-items: start; }
.split-side { display: grid; grid-template-columns: 265px 1fr; gap: 22px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 22px; }
@media (max-width: 900px) { .split-map, .split-side { grid-template-columns: 1fr; } }
#map { height: 460px; border-radius: 10px; z-index: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; border-radius: 9px; font-family: inherit; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; transition: all 0.18s ease; border: 1px solid transparent;
}
.btn-primary { background: var(--emerald-900); color: #F8F5EE; border-color: var(--gold-500); }
.btn-primary:hover { background: var(--emerald-800); }
.btn-gold { background: var(--gold-400); color: var(--emerald-950); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-outline:hover { border-color: var(--gold-500); color: var(--gold-500); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.chip {
  padding: 6px 13px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-alt); color: var(--ink); cursor: pointer;
  font-family: inherit; font-size: 0.83rem; font-weight: 500; transition: all 0.16s ease;
}
.chip:hover { border-color: var(--gold-500); }
.chip.active { background: var(--emerald-900); color: #F8F5EE; border-color: var(--gold-400); }

.side-menu { display: flex; flex-direction: column; gap: 8px; }
.side-btn {
  text-align: left; padding: 12px 15px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-alt);
  color: var(--ink); font-family: inherit; font-size: 0.88rem; font-weight: 600; cursor: pointer;
}
.side-btn.active { background: var(--emerald-900); color: #F8F5EE; border-color: var(--gold-400); }

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.92rem; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-alt); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; }
.b-ok { background: rgba(21, 115, 71, 0.13); color: var(--ok); }
.b-warn { background: rgba(168, 96, 11, 0.14); color: var(--warn); }
.b-err { background: rgba(180, 35, 24, 0.13); color: var(--err); }

.node-btn {
  text-align: left; width: 100%; padding: 15px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface-alt); color: var(--ink);
  cursor: pointer; transition: all 0.18s ease; font-family: inherit;
}
.node-btn:hover { border-color: var(--gold-500); }
.node-btn.active { border-color: var(--gold-500); background: rgba(194, 150, 59, 0.10); }

/* 6 Visual i-Think Thinking Maps */
.imap-board {
  background: var(--surface); border: 1px solid var(--border-gold);
  border-radius: 16px; padding: 26px 20px; margin-bottom: 18px;
  box-shadow: var(--shadow-sm); overflow-x: auto;
}
.imap-node {
  border: 1.5px solid var(--border-gold); background: var(--surface-alt);
  color: var(--ink); border-radius: 12px; padding: 12px 14px;
  cursor: pointer; font-family: inherit; font-weight: 600; font-size: 0.88rem;
  text-align: center; transition: all 0.18s ease; box-shadow: var(--shadow-sm);
}
.imap-node:hover { border-color: var(--gold-500); transform: translateY(-2px); }
.imap-node.active {
  background: var(--emerald-900); color: #F8F5EE; border-color: var(--gold-400);
  box-shadow: 0 6px 18px rgba(10, 48, 37, 0.25);
}
.imap-hub {
  background: linear-gradient(135deg, var(--emerald-950), var(--emerald-900));
  color: var(--gold-200); border: 2px solid var(--gold-400);
  font-family: 'Fraunces', serif; font-weight: 700; text-align: center;
  display: grid; place-items: center; padding: 12px 16px;
}

/* 1. Peta Bulatan */
.imap-circle-wrap {
  max-width: 560px; margin: 0 auto; padding: 24px;
  border: 2px dashed var(--gold-500); border-radius: 999px;
  background: radial-gradient(circle, rgba(194, 150, 59, 0.08) 0%, transparent 72%);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px;
}
.imap-circle-col { display: flex; flex-direction: column; gap: 14px; }
.imap-circle-core { width: 124px; height: 124px; border-radius: 50%; font-size: 1rem; }

/* 2. Peta Alir */
.imap-flow { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.imap-flow .imap-node { flex: 1 1 140px; min-height: 78px; display: flex; flex-direction: column; justify-content: center; }
.imap-arrow { color: var(--gold-500); font-weight: 700; font-size: 1.35rem; user-select: none; }

/* 3. Peta Pokok */
.imap-tree { display: flex; flex-direction: column; align-items: center; }
.imap-tree-root { border-radius: 10px; padding: 10px 24px; min-width: 240px; }
.imap-tree-stem { width: 2px; height: 22px; background: var(--gold-500); }
.imap-tree-bar { width: 72%; height: 2px; background: var(--gold-500); }
.imap-tree-cols { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.imap-tree-branch { display: flex; flex-direction: column; align-items: center; }
.imap-tree-branch .imap-node { width: 100%; min-height: 74px; }

/* 4. Peta Dakap */
.imap-brace { display: grid; grid-template-columns: 190px 36px 1fr; align-items: center; gap: 12px; max-width: 680px; margin: 0 auto; }
.imap-brace-root { border-radius: 12px; padding: 16px; }
.imap-brace-list { display: flex; flex-direction: column; gap: 12px; }
.imap-brace-list .imap-node { text-align: left; }

/* 5. Peta Pelbagai Alir */
.imap-multi { display: grid; grid-template-columns: 1fr 28px 160px 28px 1fr; align-items: center; gap: 10px; }
.imap-multi-core { border-radius: 12px; padding: 18px 12px; font-size: 0.98rem; }
.imap-multi-col { display: flex; flex-direction: column; gap: 12px; }

/* 6. Peta Buih Berganda */
.imap-double { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.imap-bubble {
  width: 175px; min-height: 112px; border-radius: 999px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 14px 18px;
}
.imap-bubble-mid { border-style: dashed; border-width: 2px; }
.imap-link { width: 32px; height: 2px; background: var(--gold-500); }

@media (max-width: 720px) {
  .imap-circle-wrap { border-radius: 24px; grid-template-columns: 1fr; }
  .imap-circle-core { margin: 0 auto; width: 110px; height: 110px; }
  .imap-tree-bar { display: none; }
  .imap-tree-cols { grid-template-columns: 1fr; }
  .imap-brace { grid-template-columns: 1fr; }
  .imap-brace svg { display: none; }
  .imap-multi { grid-template-columns: 1fr; }
  .imap-multi .imap-arrow { text-align: center; transform: rotate(90deg); }
  .imap-link { display: none; }
}

.dialogue-row {
  padding: 13px 15px; border-radius: 10px; margin-bottom: 10px;
  background: var(--surface-alt); border-left: 3px solid var(--gold-500);
}
.dialogue-row.alt { border-left-color: var(--emerald-800); }

details.kbat-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; background: var(--surface-alt); }
details.kbat-item summary { cursor: pointer; font-weight: 600; font-size: 0.94rem; }
details.kbat-item p { margin: 10px 0 0; }
.meter-track { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; margin: 12px 0; }
.meter-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }

.fc-stage { max-width: 660px; margin: 18px auto 14px; perspective: 1200px; }
.fc-deck-card { height: 260px; cursor: pointer; }
.fc-deck-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  transform-style: preserve-3d;
}
.fc-deck-card.flipped .fc-deck-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border: 1px solid var(--border-gold); border-radius: 18px; padding: 30px;
  background: var(--surface-alt); display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center; box-shadow: var(--shadow-md);
}
.fc-tag { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--gold-500); font-weight: 700; margin-bottom: 12px; }
.fc-front-title { font-family: 'Fraunces', serif; font-size: clamp(1.55rem, 2.8vw, 2.05rem); font-weight: 600; margin-bottom: 12px; }
.fc-back {
  transform: rotateY(180deg);
  background: linear-gradient(145deg, var(--emerald-950), var(--emerald-900));
  color: #F8F5EE; border-color: var(--gold-400);
}
.fc-back p { font-size: 1.03rem; line-height: 1.7; max-width: 540px; margin: 0; }
.fc-controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.tl-track { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tl-step {
  flex: 1 1 115px; text-align: left; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-alt); color: var(--ink);
  cursor: pointer; font-family: inherit; transition: all 0.18s ease;
}
.tl-step:hover { border-color: var(--gold-500); }
.tl-step.active { background: var(--emerald-900); color: #F8F5EE; border-color: var(--gold-400); box-shadow: var(--shadow-sm); }
.tl-era { font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; opacity: 0.8; display: block; }
.tl-title { font-weight: 700; font-size: 0.84rem; display: block; margin-top: 2px; }
.tl-stage { background: var(--surface-alt); border: 1px solid var(--border-gold); border-radius: 16px; padding: 26px; margin-bottom: 16px; }
.tl-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.dalil-box { background: var(--surface-alt); border: 1px solid var(--border-gold); border-radius: 14px; padding: 22px; margin-top: 12px; }
.dalil-ar {
  font-family: 'Amiri', serif; font-size: clamp(1.55rem, 2.5vw, 2rem);
  line-height: 1.9; text-align: right; direction: rtl;
  color: var(--emerald-900); margin: 0 0 12px;
}
body.dark .dalil-ar { color: var(--gold-200); }

input, textarea, select {
  width: 100%; padding: 10px 13px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface-alt); color: var(--ink);
  font-family: inherit; font-size: 0.93rem;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold-500); }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; margin: 14px 0 24px; }
.pod-col {
  width: 135px; text-align: center; border-radius: 12px 12px 0 0; padding: 14px 10px;
  background: var(--emerald-900); color: #F8F5EE; border-top: 3px solid var(--gold-400);
}
.pod-1 { min-height: 145px; }
.pod-2 { min-height: 115px; opacity: 0.92; }
.pod-3 { min-height: 92px; opacity: 0.85; }
.pod-rank { font-family: 'Cinzel', serif; font-size: 1.35rem; font-weight: 700; color: var(--gold-400); }
.toast { padding: 10px 14px; border-radius: 9px; font-weight: 600; margin-bottom: 12px; font-size: 0.89rem; }

body.present .hero { display: none; }
body.present .container { max-width: 1020px; padding-top: 24px; }
body.present { font-size: 18px; }
@media print {
  .topbar, .hero, .chip-row, .btn, .fc-controls, .tl-track { display: none !important; }
  .panel { display: block !important; page-break-inside: avoid; }
  body { background: #FFFFFF; color: #000000; font-size: 12pt; }
  .card { box-shadow: none; border: 1px solid #CCCCCC; }
}
