:root {
  --bg: #0b1220;
  --bg-2: #111a2e;
  --panel: rgba(17, 26, 46, 0.92);
  --line: #24314d;
  --text: #e6ecf7;
  --muted: #8a9abb;
  --accent: #4f8cff;
  --accent-2: #22c3a6;
  --warn: #f5a524;
  --danger: #f05264;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Portal ---------- */
.portal { min-height: 100%; padding: 48px 20px 64px; max-width: 1180px; margin: 0 auto; }
.portal header { margin-bottom: 36px; }
.portal h1 { font-size: clamp(26px, 4vw, 40px); margin: 0 0 8px; letter-spacing: -0.5px; }
.portal header p { color: var(--muted); margin: 0; max-width: 720px; line-height: 1.6; }
.badge { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 99px; background: rgba(79,140,255,.15); color: var(--accent); margin-bottom: 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.card { position: relative; display: flex; flex-direction: column; background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; color: var(--text); transition: transform .15s, border-color .15s; }
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card canvas { display: block; width: 100%; height: 170px; background: #0a0f1c; }
.card .body { padding: 16px 18px 20px; }
.card h2 { font-size: 18px; margin: 0 0 6px; }
.card p { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.card .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card .tags span { font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.portal footer { margin-top: 40px; color: var(--muted); font-size: 13px; }

/* ---------- Simulation layout ---------- */
.sim { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--bg-2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.topbar .back { font-size: 14px; color: var(--muted); }
.topbar .back:hover { color: var(--text); }
.topbar h1 { font-size: 17px; margin: 0; }
.tabs { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.tabs button { background: transparent; border: 1px solid var(--line); padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 13px; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.stage { position: relative; display: grid; grid-template-columns: 1fr 320px; min-height: 0; }
.viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.viewport canvas { display: block; width: 100% !important; height: 100% !important; }
.side { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 16px; }
.side h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 18px 0 10px; }
.side h3:first-child { margin-top: 0; }
.side p, .side li { font-size: 13px; line-height: 1.55; color: #c3cde2; }
.side ul { padding-left: 18px; margin: 6px 0; }

.ctrl { margin-bottom: 12px; }
.ctrl label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; color: #c3cde2; }
.ctrl label output { color: var(--accent-2); font-variant-numeric: tabular-nums; }
.ctrl input[type=range] { width: 100%; accent-color: var(--accent); }
.ctrl select, .ctrl input[type=text], .ctrl input[type=number], textarea {
  width: 100%; background: #0b1220; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; font-size: 13px;
}
.ctrl input[type=color] { width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #0b1220; padding: 2px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1; }
.btn { background: #1b2742; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ok { background: var(--accent-2); border-color: var(--accent-2); color: #04231d; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.hud { z-index: 2; position: absolute; left: 12px; top: 12px; background: rgba(8, 13, 26, .78); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; font-size: 12.5px; line-height: 1.6; pointer-events: none; max-width: 300px; font-variant-numeric: tabular-nums; }
.hud b { color: var(--accent-2); font-weight: 600; }
.hint { z-index: 2; position: absolute; left: 12px; bottom: 12px; font-size: 12px; color: var(--muted); background: rgba(8,13,26,.7); padding: 6px 10px; border-radius: 8px; pointer-events: none; }

.log { background: #070c18; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: 12px/1.5 ui-monospace, Consolas, monospace; height: 180px; overflow-y: auto; white-space: pre-wrap; color: #b6c3dd; }
.log .ok { color: var(--accent-2); } .log .err { color: var(--danger); } .log .info { color: var(--warn); }

.label3d { font-size: 12px; padding: 2px 7px; border-radius: 6px; background: rgba(8,13,26,.8); border: 1px solid var(--line); color: var(--text); white-space: nowrap; pointer-events: none; }
.label3d.small { font-size: 10.5px; padding: 1px 5px; }

table.data { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.data th, table.data td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }
table.data th { background: #16213a; color: var(--muted); font-weight: 600; position: sticky; top: 0; }
table.data tr.hl td { background: rgba(34,195,166,.15); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: #c3cde2; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.panel-section { display: none; }
.panel-section.active { display: block; }

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  .side { border-left: none; border-top: 1px solid var(--line); }
  .sim { height: auto; min-height: 100%; }
  .tabs { margin-left: 0; width: 100%; }
}

/* Label jenjang pada tab: warna seragam sekolah SD (merah), SMP (biru), SMA (abu-abu) */
.lv { display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: .3px; padding: 1px 5px; border-radius: 4px; margin-right: 5px; vertical-align: 1px; color: #fff; }
.lv.sd { background: #d93a32; } .lv.smp { background: #1f5fbf; } .lv.sma { background: #7d8594; } .lv.pt { background: #6b4fd8; }
.tabs button.active .lv { box-shadow: 0 0 0 1px rgba(255,255,255,.7); }
.card .tags span.lv { border: none; color: #fff; font-size: 10.5px; }
.formula { font-family: "Cambria Math", Georgia, serif; font-size: 14px; background: #0b1220; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 6px 0; color: #dfe7f7; }
canvas.chart { width: 100%; height: 150px; background: #070c18; border: 1px solid var(--line); border-radius: 8px; display: block; }
