/* Tema kertas kotak-kotak, margin merah, tinta biru, koreksi pena merah.
   Selalu terang. Tidak ada mode gelap otomatis. */
:root {
  --bg: #f3f7fa; --surface: #ffffff; --surface2: #eef3f8; --ink: #1b2233; --muted: #56627a; --line: #c8d4e1; --grid: #d9e6f0;
  --accent: #1f3fbf; --accent-ink: #ffffff; --amber: #8a5a00; --amber-bg: #fbf1d8;
  --good: #1b6f43; --good-bg: #e3f3ea; --bad: #c62828; --bad-bg: #fbe6e5; --pen: #d3302f;
  --code-bg: #f4f8fc; --code-ink: #1b2233;
  --f-head: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.6; background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px;
  padding: 0 max(0px, env(safe-area-inset-right, 0px)) 48px max(0px, env(safe-area-inset-left, 0px)); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); }
h1, h2, h3 { font-family: var(--f-head); font-weight: 700; margin: 0; text-wrap: balance; letter-spacing: -.005em; }
h1 { font-size: 34px; line-height: 1.1; } h2 { font-size: 24px; line-height: 1.2; } h3 { font-size: 18px; line-height: 1.25; }
p { margin: 0; max-width: 68ch; } a { color: var(--accent); text-underline-offset: 3px; } .muted { color: var(--muted); } .small { font-size: 14px; }
.mono { font-family: var(--f-mono); }

/* lembar */
.shell { max-width: 1040px; margin: 0 auto; background: var(--surface); min-height: 100vh; position: relative; border-left: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0 28px 40px 76px; }
.shell::before, .shell::after { content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--pen); opacity: .55; pointer-events: none; }
.shell::before { left: 48px; } .shell::after { left: 52px; }
header.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); padding-block: 18px 0; border-bottom: 1.5px solid var(--ink); }
.brand { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; }
.brand b { font-family: var(--f-head); font-size: 22px; letter-spacing: -.005em; } .brand span { color: var(--muted); font-size: 14px; }
nav#nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin: 8px 0 -1.5px -10px; } nav#nav::-webkit-scrollbar { display: none; }
nav#nav a { white-space: nowrap; text-decoration: none; color: var(--muted); font-weight: 500; padding: 10px 10px; border-bottom: 3px solid transparent; min-height: 44px; display: flex; align-items: center; }
nav#nav a:hover { color: var(--ink); }
nav#nav a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
main { display: flex; flex-direction: column; gap: 40px; padding-block: 28px 8px; }

/* blok isi: dipisah garis, bukan kotak */
.card { background: transparent; border: 0; border-top: 1.5px solid var(--ink); border-radius: 0; padding: 12px 0 0; min-width: 0; }
.card .card { border-top: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; } .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grid { display: grid; gap: 22px 28px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); } .grid > * { min-width: 0; }
.lbl { font-size: 14px; color: var(--muted); font-weight: 500; }
a.card { text-decoration: none; color: inherit; } a.card:hover { background: var(--surface2); } a.card:hover b, a.card:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
a.card .go { color: var(--accent); font-size: 14px; font-weight: 600; margin-top: auto; }

/* tag status */
.chip { white-space: nowrap; display: inline-block; font-size: 13px; font-weight: 500; padding: 0 7px; border-radius: 2px; width: fit-content; border: 1px solid var(--line); color: var(--muted); background: var(--surface); line-height: 20px; }
.chip.ok { border-color: var(--good); color: var(--good); } .chip.ok::before { content: "\2713\00a0"; }
.chip.bad { border-color: var(--bad); color: var(--bad); } .chip.warn { border-color: var(--amber); color: var(--amber); background: var(--amber-bg); }

/* kontrol */
button, select, input, textarea { font: inherit; color: inherit; }
button, a.btn { cursor: pointer; border: 1.5px solid var(--ink); background: var(--surface); border-radius: 2px; padding: 8px 16px; font-weight: 500; text-decoration: none; color: var(--ink); min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
button:hover:not(:disabled), a.btn:hover { background: var(--surface2); } button:disabled { opacity: .45; cursor: not-allowed; }
button.primary, a.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover:not(:disabled), a.btn.primary:hover { background: #172f94; }
button.small, a.btn.small { min-height: 34px; padding: 3px 11px; font-size: 14px; border-width: 1px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input[type=text], input:not([type]), select { background: var(--surface); border: 1.5px solid var(--ink); border-radius: 2px; padding: 8px 12px; min-height: 44px; }
input[type=radio], input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; flex: none; }

/* progres */
.bar-p { height: 8px; background: var(--surface2); border: 1px solid var(--line); } .bar-p i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.hero { display: grid; grid-template-columns: 1fr 220px; gap: 28px; align-items: center; } .hero > * { min-width: 0; }
.hero .card { border-top: 0; padding-top: 0; }
.score { justify-self: center; text-align: center; color: var(--pen); font-family: var(--f-head); transform: rotate(-5deg); padding: 22px 26px 16px; border: 3px solid var(--pen); border-radius: 52% 48% 55% 45% / 58% 50% 50% 42%; line-height: 1; }
.score b { display: block; font-size: 58px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; } .score span { display: block; font-family: var(--f-body); font-size: 13px; margin-top: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; } .stat b { display: block; font-family: var(--f-head); font-size: 26px; font-variant-numeric: tabular-nums; } .stat span { font-size: 13px; color: var(--muted); }
.stage { display: flex; flex-direction: column; gap: 10px; }
.stage .top { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.stage ul { margin: 0; padding-left: 20px; color: var(--muted); font-size: 15px; }
.check { display: flex; gap: 10px; align-items: center; min-height: 36px; cursor: pointer; } .check input { width: 20px; height: 20px; }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; } th { font-weight: 600; border-bottom: 1.5px solid var(--ink); } .scroll { overflow-x: auto; }
td.r, th.r { text-align: right; }

/* code lab */
.lab { display: grid; grid-template-columns: 240px 1fr; gap: 28px; align-items: start; } .lab > * { min-width: 0; }
.exlist { display: flex; flex-direction: column; gap: 0; position: sticky; top: 132px; max-height: calc(100vh - 160px); overflow-y: auto; border-top: 1.5px solid var(--ink); }
.exbtn { text-align: left; display: flex; justify-content: space-between; gap: 8px; align-items: center; width: 100%; min-height: 44px; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 6px 8px; font-weight: 400; }
.exbtn[aria-current="true"] { background: var(--surface2); box-shadow: inset 3px 0 0 var(--accent); font-weight: 600; }
.editor { width: 100%; min-height: 280px; resize: vertical; background: var(--code-bg); color: var(--code-ink); border: 1.5px solid var(--ink); border-radius: 2px; padding: 12px; font-family: var(--f-mono); font-size: 14px; line-height: 1.6; tab-size: 2; white-space: pre; overflow: auto; }
pre.code { margin: 0; background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--line); border-radius: 2px; padding: 12px; overflow-x: auto; font-family: var(--f-mono); font-size: 13.5px; line-height: 1.55; }
.out { display: flex; flex-direction: column; gap: 0; }
.t { display: flex; gap: 10px; align-items: flex-start; padding: 7px 10px; border-bottom: 1px solid var(--line); border-left: 4px solid var(--line); background: var(--surface); }
.t.ok { border-left-color: var(--good); } .t.bad { border-left-color: var(--bad); background: var(--bad-bg); }
.t .m { font-family: var(--f-mono); font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.log { font-family: var(--f-mono); font-size: 13px; background: var(--code-bg); border: 1px solid var(--line); border-radius: 2px; padding: 10px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow: auto; }
.kbd { font-family: var(--f-mono); font-size: 13px; background: var(--surface2); border: 1px solid var(--line); border-radius: 2px; padding: 0 5px; }

/* panel lipat */
details > summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; gap: 8px; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 7px; height: 7px; flex: none; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(-45deg); transition: transform .15s; margin: 0 4px 0 2px; }
details[open] > summary::before { transform: rotate(45deg); }

/* quiz & progress */
fieldset.q { border: 0; border-top: 1px solid var(--line); padding: 14px 0 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
fieldset.q legend { font-weight: 600; padding: 0; float: left; width: 100%; margin-bottom: 8px; } fieldset.q legend + * { clear: both; }
label.opt { display: flex; gap: 12px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 2px; cursor: pointer; min-height: 44px; background: var(--surface); }
label.opt input { margin-top: 3px; }
label.opt:hover { border-color: var(--ink); }
label.opt:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
label.opt.right { border-color: var(--good); background: var(--good-bg); }
label.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
textarea.codebox { width: 100%; font-family: var(--f-mono); font-size: 13px; word-break: break-all; background: var(--code-bg); border: 1.5px solid var(--ink); border-radius: 2px; padding: 10px 12px; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 500; }
.form input[type=text] { width: 100%; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; } .lab { grid-template-columns: 1fr; gap: 16px; }
  .exlist { position: static; max-height: none; overflow-y: visible; flex-direction: row; overflow-x: auto; border-top: 0; gap: 6px; padding-bottom: 4px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
  .exbtn { width: auto; white-space: nowrap; flex: none; border: 1px solid var(--line); }
  .exbtn[aria-current="true"] { border-color: var(--accent); box-shadow: none; }
  .score { justify-self: start; }
}
@media (max-width: 640px) {
  .shell { padding: 0 16px 32px 28px; border: 0; } .shell::before { left: 14px; } .shell::after { left: 17px; }
  h1 { font-size: 28px; } h2 { font-size: 22px; } main { padding-block: 20px 4px; gap: 22px; }
  header.bar { padding-block: 12px 0; } .brand { flex-wrap: nowrap; } .brand span#sum { display: none; } .brand b { font-size: 20px; }
  nav#nav { margin-left: -8px; margin-top: 2px; padding-right: 24px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
  nav#nav a { padding: 8px 10px; }
  .editor { font-size: 16px; min-height: 240px; } .row > button, .row > a.btn { flex: 1 1 auto; }
  .score b { font-size: 48px; } button.small, a.btn.small { min-height: 38px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
a.btn.small { border: 0; background: transparent; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; padding: 3px 4px; }
a.btn.small:hover { background: var(--surface2); }
@media (max-width: 640px) { .row > button.small { flex: 0 0 auto; } .row > a.btn.small { flex: 0 0 auto; } }

/* glossary */
input[type=search] { background: var(--surface); border: 1.5px solid var(--ink); border-radius: 2px; padding: 8px 12px; min-height: 44px; width: 100%; max-width: 520px; }
button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.gloss { margin: 0; display: flex; flex-direction: column; }
.gl { font-family: var(--f-head); font-weight: 700; font-size: 22px; color: var(--pen); border-bottom: 1.5px solid var(--ink); padding: 18px 0 2px; scroll-margin-top: 140px; }
.ge { padding: 10px 0; border-bottom: 1px solid var(--line); }
.ge dt { font-weight: 600; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; } .ge dd { margin: 4px 0 0; display: flex; flex-direction: column; gap: 4px; }
.ge .chip { font-weight: 400; font-size: 12px; }
