* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 400 13px/1.55 var(--mono); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--dlg-a); outline-offset: 2px; }
h1, h2, h3, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }

.app { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 9px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-size: 18px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.brand svg { width: 28px; height: 28px; }
.topnav { display: flex; gap: 2px; margin-left: 22px; }
.topnav > * { border: 1px solid transparent; background: none; padding: 7px 14px; border-radius: var(--r-control); text-decoration: none; font-weight: 500; white-space: nowrap; }
.topnav [aria-current] { background: var(--leaf); color: var(--leaf-ink); border-color: var(--hard); box-shadow: 2px 3px 0 var(--hard); font-weight: 600; }
.topnav button:disabled { color: var(--muted); cursor: not-allowed; }
.search { display: flex; align-items: center; gap: 8px; margin-left: auto; width: min(330px, 28vw); height: 36px; padding: 0 9px 0 11px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-control); }
.search:focus-within { border-color: var(--ink); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; }
.search input::placeholder { color: var(--muted); }
kbd { font: 500 11px var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; background: var(--surface); white-space: nowrap; }
.icon-btn { display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px; padding: 0; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-control); cursor: pointer; }
.icon-btn:hover { border-color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }
#menuBtn { display: none; }

.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr) 350px; gap: 14px; min-height: 0; padding: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }

.sidebar { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.course { flex: 1; min-height: 0; overflow: auto; padding: 14px 10px; }
.course-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 8px 10px; }
.course-head h2 { font-size: 15px; font-weight: 700; }
.course-head span { color: var(--muted); font-size: 12px; }
.module summary { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--r-control); cursor: pointer; font-weight: 600; list-style: none; }
.module summary::-webkit-details-marker { display: none; }
.module summary:hover { background: var(--raised); }
.module summary .chev { width: 12px; flex: none; transition: transform .15s; }
.module[open] summary .chev { transform: rotate(90deg); }
.module summary small { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
.lessons { margin: 2px 0 8px 14px; padding-left: 10px; border-left: 1px solid var(--line); }
.lesson { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 1px solid transparent; border-radius: var(--r-control); text-decoration: none; line-height: 1.35; }
a.lesson:hover { background: var(--raised); }
.lesson[aria-current] { background: var(--leaf); color: var(--leaf-ink); border-color: var(--hard); box-shadow: 2px 3px 0 var(--hard); font-weight: 600; }
.lesson.soon { color: var(--muted); }
.lesson small { margin-left: auto; font-size: 11px; }
.lesson i { flex: none; width: 13px; height: 13px; border: 1.5px solid currentColor; border-radius: 50%; opacity: .6; }
.lesson.done i { background: var(--media); border-color: var(--media); opacity: 1; }
.empty { padding: 10px 8px; color: var(--muted); }
.progress { padding: 13px 16px 15px; }
.progress div:first-child { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 8px; }
.bar { height: 11px; background: var(--raised); border: 1px solid var(--ink); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--leaf); border-right: 1px solid var(--ink); transition: width .3s; }

.main { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; overflow: auto; padding: 16px; }
.crumbs { color: var(--muted); font-size: 12px; }
.head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 14px; align-items: center; }
.head h1 { font-size: 30px; line-height: 1.12; letter-spacing: -.035em; font-weight: 700; }
.head p { grid-column: 1 / -1; color: var(--muted); max-width: 90ch; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border: 1px solid var(--ink); border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip.sun { background: var(--sun); color: var(--sun-ink); }
.chip.leaf { background: var(--leaf); color: var(--leaf-ink); }
.chip.lilac { background: var(--lilac); color: var(--lilac-ink); }
.chip.rose { background: var(--rose); color: var(--rose-ink); }

.stage { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 410px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.stage-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px; }
.metrics { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }
.metric { padding: 5px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control); }
.metric span { display: block; color: var(--muted); font-size: 11px; white-space: nowrap; }
.metric b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; }
.metric.total { border-left: 3px solid var(--dlg-b); }
.stage-actions { display: flex; gap: 6px; align-items: flex-start; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 12px; background: var(--raised); border: 1px solid var(--ink); border-radius: var(--r-control); cursor: pointer; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--surface); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { flex: 1; min-width: 0; white-space: normal; text-align: left; justify-content: space-between; background: var(--leaf); color: var(--leaf-ink); border-color: var(--hard); box-shadow: 2px 3px 0 var(--hard); line-height: 1.25; }
.btn.primary:hover:not(:disabled) { background: var(--leaf); transform: translate(1px, 1px); box-shadow: 1px 2px 0 var(--hard); }
#scene { display: block; flex: 1; width: 100%; min-height: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 2px 12px 9px; color: var(--muted); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; }

.rail { padding: 11px 12px 10px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-card); }
.rail-head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12px; }
.rail-head b { font-weight: 700; } .rail-head span { color: var(--muted); }
.phases { position: relative; display: grid; row-gap: 5px; overflow-x: auto; padding: 2px 2px 3px; }
.phase { grid-row: 1; margin: 0 2px; padding-bottom: 2px; border-bottom: 2px solid var(--line); color: var(--muted); font-size: 10.5px; text-align: center; white-space: nowrap; }
.phase.current { color: var(--ink); border-color: var(--ink); font-weight: 700; }
.dot { position: relative; grid-row: 2; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; padding: 0; background: none; border: 0; cursor: pointer; }
.dot:not(:last-child)::after { content: ""; position: absolute; top: 12px; left: 50%; width: 100%; height: 2px; background: var(--line); }
.dot.done::after { background: var(--ink); }
.dot b { position: relative; z-index: 1; display: grid; place-items: center; width: 26px; height: 26px; background: var(--raised); border: 1.5px solid var(--line); border-radius: 50%; color: var(--muted); font-size: 11px; font-weight: 600; }
.dot:hover b { border-color: var(--ink); }
.dot.done b { background: var(--surface); border-color: var(--ink); color: var(--ink); }
.dot.active b { background: var(--leaf); color: var(--leaf-ink); border-color: var(--hard); box-shadow: 1px 2px 0 var(--hard); }
.dot span { border-bottom: 2px solid var(--c, transparent); color: var(--muted); font-size: 10.5px; line-height: 1.35; white-space: nowrap; }
.dot.active span { color: var(--ink); font-weight: 700; }

.detail { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; }
.explain { padding: 16px; flex: none; }
.explain-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 9px; font-weight: 600; font-size: 12px; }
.explain h2 { font-size: 18px; line-height: 1.25; letter-spacing: -.02em; margin-bottom: 8px; }
.explain > p { max-width: 72ch; }
.verify { margin-top: 9px; padding: 5px 9px; background: var(--sun); color: var(--sun-ink); border-radius: var(--r-control); font-size: 12px; }
.note { margin-top: 11px; padding: 10px 11px; background: color-mix(in srgb, var(--leaf) 42%, var(--surface)); border: 1px solid var(--leaf); border-radius: var(--r-card); font-size: 12.5px; }
.note b { display: block; margin-bottom: 2px; color: var(--leaf-ink); font-size: 12px; }
.changes { margin-top: 11px; }
.changes h3 { color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 3px; }
.changes li { font-size: 12.5px; }
.changes li b { font-weight: 600; }
.explain-nav { display: flex; gap: 8px; margin-top: 13px; }
.keys { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 10px; color: var(--muted); font-size: 11px; }

.info { display: flex; flex-direction: column; flex: 1 0 280px; min-height: 280px; overflow: hidden; }
.tabs { display: flex; gap: 2px; padding: 7px 8px 0; border-bottom: 1px solid var(--line); }
.tab { padding: 7px 10px 8px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab-body { flex: 1; min-height: 0; overflow: auto; padding: 11px 14px 14px; }
pre.raw { margin: 0; font: 400 11.5px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
pre.raw mark { background: var(--mark); color: var(--mark-ink); border-radius: 3px; padding: 0 2px; font-weight: 500; }
.dcard { padding: 9px 11px; margin-bottom: 9px; background: var(--raised); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: var(--r-control); }
.dcard h3 { display: flex; justify-content: space-between; font-size: 13px; color: var(--c); margin-bottom: 4px; }
.dcard h3 span { color: var(--ink); font-weight: 500; font-size: 12px; }
.dcard dl { display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 1px 8px; font-size: 11.5px; }
.dcard dt { color: var(--muted); }
.dcard dd { overflow-wrap: anywhere; }
.goals li { position: relative; padding: 0 0 8px 23px; }
.goals li::before { content: "✓"; position: absolute; left: 0; top: 2px; display: grid; place-items: center; width: 15px; height: 15px; background: var(--leaf); color: var(--leaf-ink); border: 1px solid var(--ink); border-radius: 4px; font-size: 10px; font-weight: 700; }

.backdrop { display: none; }
.scene-chip rect { fill: var(--raised); stroke: var(--ink); stroke-width: 1.2; }
.scene-chip text { fill: var(--ink); font-family: var(--mono); font-weight: 600; }
#pulse { opacity: 0; fill: none; stroke: var(--media); stroke-width: 3; transform-box: fill-box; transform-origin: center; }
#pulse.on { animation: pulse .8s ease-out; }
@keyframes pulse { 0% { opacity: .8; transform: scale(.9); } 100% { opacity: 0; transform: scale(1.3); } }
.hex-pulse { opacity: 0; fill: none; stroke: var(--media); stroke-width: 3; transform-box: fill-box; transform-origin: center; }
.hex-pulse.on { animation: pulse .8s ease-out; }

@media (max-width: 1359px) {
  .shell { grid-template-columns: minmax(0, 1fr) 340px; }
  .stage { flex: none; min-height: 520px; }
  #menuBtn { display: inline-grid; }
  .topnav { margin-left: 8px; }
  .sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: min(330px, 88vw); padding: 12px; background: var(--paper); border-right: 1px solid var(--ink); transform: translateX(-102%); visibility: hidden; transition: transform .2s, visibility .2s; }
  .sidebar.open { transform: none; visibility: visible; }
  .backdrop.open { display: block; position: fixed; z-index: 20; inset: 0; background: rgb(20 20 16 / .4); border: 0; }
}
@media (max-width: 999px) {
  .app { display: block; height: auto; }
  .topbar { flex-wrap: wrap; position: sticky; top: 0; z-index: 10; padding: 8px 16px; }
  .topnav { order: 5; width: 100%; margin: 0; overflow-x: auto; padding: 0 3px 4px; }
  .search { width: auto; flex: 1; min-width: 130px; }
  .shell { display: block; padding: 12px 16px 24px; }
  .main { overflow: visible; margin-bottom: 12px; padding: 13px; }
  .detail { overflow: visible; }
  .info { min-height: 0; max-height: 460px; flex: none; }
  .stage { min-height: 0; }
  #scene { flex: none; height: auto; aspect-ratio: 860 / 484; }
  body { padding-bottom: 76px; }
  .keys { display: none; }
  .explain-nav { position: fixed; z-index: 9; left: 0; right: 0; bottom: 0; margin: 0; padding: 9px 16px calc(9px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--ink); }
}
@media (max-width: 560px) {
  .brand span { display: none; }
  .search kbd { display: none; }
  .head h1 { font-size: 25px; }
  .metrics { flex-wrap: nowrap; width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .metric { flex: none; }
  .head { grid-template-columns: minmax(0, 1fr); }
  .chips { justify-content: flex-start; }
  .stage-actions { width: 100%; }
  .stage-actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Warna packet untuk lesson dengan satu dialog, varian, dan latihan */
.brand { color: inherit; text-decoration: none; }
.lesson > span { min-width: 0; }
.phases { padding-bottom: 11px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.phase { text-align: left; }
.phase span { position: sticky; left: 2px; display: inline-block; }
.dot:disabled { cursor: default; }
.dot:disabled:hover b { border-color: var(--line); }
.dot.done:disabled:hover b, .dot.active:disabled:hover b { border-color: var(--ink); }
.variant { display: inline-flex; align-items: center; gap: 7px; width: fit-content; margin: 0 10px 4px; font-size: 12px; font-weight: 600; cursor: pointer; }
.variant input { width: 15px; height: 15px; accent-color: var(--moh); }


/* Diagram tumbuh dan metrik yang berubah */
#scene .reveal { transform-box: fill-box; transform-origin: center; animation: node-in .55s cubic-bezier(.2, .8, .2, 1); }
@keyframes node-in { from { opacity: 0; transform: translateY(14px) scale(.94); } }
.metric.changed { animation: metric-glow 1.7s ease-out; }
@keyframes metric-glow {
  0%, 35% { background: var(--leaf); border-color: var(--hard); box-shadow: 0 0 0 3px color-mix(in srgb, var(--leaf) 70%, transparent); }
  100% { box-shadow: 0 0 0 3px transparent; }
}

.quiz { margin-top: 13px; padding-top: 12px; border-top: 1px solid var(--line); }
.quiz-score { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: 12px; }
.quiz-score b { color: var(--ink); }
.quiz-q { margin-bottom: 8px; font-weight: 600; }
.quiz-wait { color: var(--muted); }
.quiz-result { margin-bottom: 10px; }
.quiz-options { display: grid; gap: 6px; }
.quiz-option { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 6px 9px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-control); font-size: 12.5px; font-weight: 500; text-align: left; cursor: pointer; }
.quiz-option:hover:not(:disabled) { border-color: var(--ink); }
.quiz-option:disabled { cursor: default; }
.quiz-option.right { background: var(--leaf); color: var(--leaf-ink); border-color: var(--hard); box-shadow: 2px 3px 0 var(--hard); font-weight: 600; }
.quiz-option.wrong { background: var(--rose); color: var(--rose-ink); border-color: var(--rose-ink); }
.quiz-feedback { min-height: 20px; margin-top: 6px; font-size: 12.5px; font-weight: 600; }
.quiz-feedback.ok { color: var(--leaf-ink); }
.quiz-feedback.no { color: var(--rose-ink); }
.quiz-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.quiz-actions .btn.primary { flex: 1 1 180px; }

@media (max-width: 999px) {
  .quiz-option { min-height: 44px; }
}

/* Nama produk panjang: satu baris di layar lebar, dua baris saat ruang topbar sempit. */
.brand-name { display: block; line-height: 1.08; }
.brand-break { display: none; }
@media (max-width: 1499px) {
  .brand { font-size: 14px; gap: 8px; }
  .brand-break { display: inline; }
}
@media (max-width: 560px) {
  .brand { font-size: 12px; gap: 6px; }
  .brand span.brand-name { display: block; }
  .topbar { gap: 8px; }
  .search { min-width: 0; }
}

/* Jalan pulang ke portofolio saat web ini dibuka dari menu portofolio. */
.topnav .back-home { color: var(--muted); margin-right: 6px; }
.topnav .back-home:hover, .topnav .back-home:focus-visible { color: var(--ink); }
@media (min-width: 1000px) and (max-width: 1359px) {
  .topbar .search { flex: 1 1 150px; width: auto; min-width: 150px; max-width: 330px; }
}

/* Pemilih bahasa: tombol globe + kode, dropdown berisi nama asli dan nama dalam bahasa aktif. */
.i18n-wait .app { visibility: hidden; }
.lang { position: relative; flex: none; }
.lang-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 9px 0 10px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-control); font: 600 12px var(--mono); letter-spacing: .02em; cursor: pointer; }
.lang-btn:hover, .lang-btn[aria-expanded="true"] { border-color: var(--ink); }
.lang-btn svg { width: 17px; height: 17px; }
.lang-btn .lang-chev { width: 10px; height: 10px; color: var(--muted); transition: transform .15s; }
.lang-btn[aria-expanded="true"] .lang-chev { transform: rotate(180deg); }
.lang-menu { position: absolute; z-index: 50; top: calc(100% + 8px); right: 0; display: grid; gap: 2px; width: 236px; padding: 6px; background: var(--surface); border: 1px solid var(--ink); border-radius: var(--r-card); box-shadow: 3px 4px 0 var(--hard); }
.lang-menu[hidden] { display: none; }
.lang-menu button { display: grid; grid-template-columns: auto minmax(0, 1fr) 16px; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 5px 8px; background: none; border: 1px solid transparent; border-radius: var(--r-control); color: inherit; text-align: left; cursor: pointer; }
.lang-menu button:hover, .lang-menu button:focus-visible { background: var(--raised); border-color: var(--line); outline: none; }
.lang-menu button[aria-checked="true"] { background: var(--leaf); color: var(--leaf-ink); border-color: var(--hard); }
.lang-badge { display: grid; place-items: center; width: 30px; height: 22px; border: 1px solid currentColor; border-radius: 6px; font: 600 10.5px var(--mono); letter-spacing: .04em; }
.lang-names { display: grid; line-height: 1.25; }
.lang-names b { font-weight: 600; }
.lang-names small { color: var(--muted); font-size: 11px; }
.lang-menu button[aria-checked="true"] small { color: inherit; opacity: .8; }
.lang-check { width: 16px; height: 16px; visibility: hidden; }
.lang-menu button[aria-checked="true"] .lang-check { visibility: visible; }
@media (max-width: 560px) {
  .lang-btn { gap: 4px; padding: 0 7px; }
  .lang-btn .lang-chev { display: none; }
  .lang-menu { right: -44px; width: min(236px, calc(100vw - 32px)); }
}
