/* PBO Playground — tema gelap, warna sintaks mengikuti deck slide PBO. */
:root {
  --bg: #0b1120;
  --panel: #111827;
  --panel-2: #0f172a;
  --line: #1f2a3d;
  --line-2: #2b3a52;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --faint: #64748b;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --accent-ink: #1c1206;
  --ok: #4ade80;
  --err: #f87171;
  --err-bg: rgba(248, 113, 113, 0.12);
  --warn: #facc15;
  --warn-bg: rgba(250, 204, 21, 0.1);
  --pink: #f472b6;
  --sky: #7dd3fc;
  --green: #86efac;
  --orange: #fdba74;
  --mono: Consolas, "Cascadia Mono", "JetBrains Mono", ui-monospace, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); display: flex; flex-direction: column; }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; margin-right: auto; font-size: 16px; }
.brand .logo { font-size: 22px; }
.pilih-contoh { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
select { background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 10px; }
.top button { background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.top button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.top button.primary:hover { background: var(--accent-2); }
.top button.ghost { background: transparent; }

/* ---------- tata letak: editor | layar ---------- */
.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(360px, 1fr) minmax(440px, 1.3fr); }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.editor-pane { border-right: 1px solid var(--line); }
@media (max-width: 900px) {
  html, body { height: auto; }
  .layout { display: flex; flex-direction: column; }
  .editor-pane { height: 60vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .konsol { max-height: 35vh; }
}

/* ---------- editor ---------- */
.tabs { display: flex; overflow-x: auto; background: var(--panel-2); border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.tab { display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 12px; border: 0; border-right: 1px solid var(--line); border-top: 2px solid transparent; background: none; cursor: pointer; color: var(--muted); font: 13px var(--mono); white-space: nowrap; }
.tab.on { color: var(--text); background: var(--panel); border-top-color: var(--accent); }
.tab .x { opacity: .4; padding: 0 4px; border-radius: 4px; }
.tab .x:hover { opacity: 1; background: var(--line-2); }
.tab .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--err); }
.tab.tambah { color: var(--accent); font-family: var(--sans); padding: 7px 12px; }
.tampilan-bar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; background: var(--panel); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.tampilan-bar label { display: flex; align-items: center; gap: 10px; }
.tampilan-bar select { min-width: 200px; }
.tampilan-bar label[hidden], .main-note[hidden] { display: none; }
#ifaceNote { color: var(--sky); }
.main-note { color: var(--accent-2); }
.main-note code { font-family: var(--mono); }
.tab .ik-main { color: var(--accent); font-size: 11px; }
/* dialog class baru */
#dlgBaru { width: min(440px, calc(100vw - 32px)); }
.form-baru { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.form-baru h2 { margin: 0; font-size: 18px; }
.form-baru .isian { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.form-baru .isian input { background: var(--panel-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; font: 15px var(--mono); }
.form-baru .centang { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.form-baru .centang input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.form-baru code { font-family: var(--mono); color: var(--accent-2); }
.form-baru .pesan { margin: 0; color: var(--err); font-size: 13px; min-height: 1em; }
.form-baru .tombol-form { display: flex; justify-content: flex-end; gap: 8px; }
.form-baru button { background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 16px; cursor: pointer; }
.form-baru button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.editor { flex: 1; min-height: 0; position: relative; }
.editor .CodeMirror, .editor textarea { position: absolute; inset: 0; height: 100%; }
.editor textarea { width: 100%; background: var(--panel); color: var(--text); border: 0; padding: 10px; font: 14px/1.5 var(--mono); resize: none; tab-size: 4; }
.masalah { max-height: 120px; overflow: auto; border-top: 1px solid var(--line); background: var(--panel-2); font-size: 13px; }
.masalah:empty { display: none; }
.masalah .item { display: flex; gap: 8px; padding: 5px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.masalah .item:hover { background: var(--panel); }
.masalah .lok { font-family: var(--mono); color: var(--muted); white-space: nowrap; }
.masalah .err .ikon { color: var(--err); }
.masalah .warn .ikon { color: var(--warn); }
.masalah .ok { color: var(--ok); padding: 5px 12px; }

/* CodeMirror tema "pbo" */
.cm-s-pbo.CodeMirror { background: var(--panel); color: var(--text); font: 14px/1.55 var(--mono); }
.cm-s-pbo .CodeMirror-gutters { background: var(--panel); border-right: 1px solid var(--line); }
.cm-s-pbo .CodeMirror-linenumber { color: #475569; }
.cm-s-pbo .CodeMirror-cursor { border-left: 2px solid var(--accent); }
.cm-s-pbo .CodeMirror-selected, .cm-s-pbo.CodeMirror-focused .CodeMirror-selected { background: #1e3a5f; }
.cm-s-pbo .cm-keyword { color: var(--pink); font-weight: 600; }
.cm-s-pbo .cm-type, .cm-s-pbo .cm-variable-3 { color: var(--sky); }
.cm-s-pbo .cm-string { color: var(--green); }
.cm-s-pbo .cm-comment { color: var(--muted); font-style: italic; }
.cm-s-pbo .cm-number, .cm-s-pbo .cm-atom { color: var(--orange); }
.cm-s-pbo .cm-meta { color: var(--warn); }
.cm-s-pbo .cm-def { color: #fde68a; }
.cm-s-pbo .cm-variable, .cm-s-pbo .cm-property { color: var(--text); }
.cm-s-pbo .CodeMirror-matchingbracket { color: var(--accent-2) !important; text-decoration: underline; }
.cm-s-pbo .baris-error { background: var(--err-bg); box-shadow: inset 3px 0 var(--err); }
.cm-s-pbo .baris-warn { background: var(--warn-bg); box-shadow: inset 3px 0 var(--warn); }
.cm-s-pbo .baris-loncat { animation: kilat 1.2s ease-out; }
@keyframes kilat { from { background: rgba(245, 158, 11, .35); } to { background: transparent; } }

/* saran setelah titik (CodeMirror show-hint) */
.CodeMirror-hints { background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; box-shadow: 0 10px 28px rgba(0,0,0,.5); padding: 4px 0; font: 13px var(--mono); max-height: 260px; z-index: 50; }
.CodeMirror-hint { color: var(--text); padding: 3px 10px; display: flex; align-items: center; gap: 8px; border-radius: 0; white-space: nowrap; }
li.CodeMirror-hint-active { background: #1e3a5f; color: #fff; }
.CodeMirror-hint .h-ik { width: 16px; height: 16px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; font: 700 10px var(--sans); color: #0f172a; flex: none; }
.CodeMirror-hint .h-m { background: var(--pink); }
.CodeMirror-hint .h-f { background: var(--sky); }
.CodeMirror-hint .h-tipe { margin-left: auto; padding-left: 18px; color: var(--muted); font-size: 12px; }
.CodeMirror-hint { position: relative; }
/* judul kelompok: Milik X / Warisan dari Y / Bawaan playground */
.CodeMirror-hint.h-awal { margin-top: 20px; }
.CodeMirror-hint.h-awal:first-child { margin-top: 18px; }
.CodeMirror-hint.h-awal::before { content: attr(data-grup); position: absolute; left: 0; right: 0; top: -19px; padding: 2px 10px; font: 700 10.5px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--accent-2); background: var(--panel); border-top: 1px solid var(--line-2); }
.CodeMirror-hint.h-awal:first-child::before { border-top: 0; }
.CodeMirror-hint.h-milik .h-nama { font-weight: 700; }
.CodeMirror-hint.h-warisan::before { color: var(--sky); }
.CodeMirror-hint.h-bawaan::before { color: var(--faint); }
.CodeMirror-hint.h-bawaan .h-nama, .CodeMirror-hint.h-bawaan .h-tipe { color: var(--faint); }
.CodeMirror-hint.h-bawaan .h-ik { background: #475569; color: #e2e8f0; }
li.CodeMirror-hint-active.h-bawaan .h-nama { color: #fff; }

/* ---------- layar ---------- */
.stage-wrap { position: relative; padding: 12px 12px 0; display: flex; justify-content: center; }
#layar { width: 100%; max-width: 800px; aspect-ratio: 4 / 3; height: auto; max-height: calc(100vh - 250px); object-fit: contain; display: block; background: #0f172a; border-radius: 10px; border: 1px solid var(--line-2); }
@media (max-width: 900px) { #layar { max-height: none; } }
.stage-hint { position: absolute; inset: 12px 12px 0; display: flex; align-items: center; justify-content: center; color: var(--muted); pointer-events: none; font-size: 15px; }
.stage-hint[hidden] { display: none; }
.lewati { position: absolute; right: 22px; bottom: 10px; background: rgba(15, 23, 42, .85); border: 1px solid var(--line-2); border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 12.5px; }
.lewati[hidden] { display: none; }

/* kartu objek (muncul saat objek diklik) */
.kartu { position: absolute; z-index: 2; min-width: 210px; max-width: 300px; background: #fffbeb; color: #1c1206; border: 2px solid #f59e0b; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 13px; overflow: hidden; }
.kartu[hidden] { display: none; }
.kartu .k-head { background: #f59e0b; padding: 6px 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.kartu .k-head b { font: 700 14px var(--mono); text-decoration: underline; }
.kartu .k-head small { font-size: 11.5px; }
.kartu table { width: 100%; border-collapse: collapse; font: 12.5px/1.4 var(--mono); }
.kartu td { padding: 4px 10px; border-top: 1px dashed #fcd34d; vertical-align: top; }
.kartu .t { color: #0369a1; white-space: nowrap; }
.kartu .v { text-align: right; color: #9a3412; font-weight: 600; word-break: break-word; }
.kartu .kosong { padding: 8px 10px; color: #78716c; font-style: italic; }

.konsol-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.status { text-transform: none; letter-spacing: 0; font-family: var(--mono); }
.status.jalan { color: var(--ok); }
.status.gagal { color: var(--err); }
.konsol { flex: 1; min-height: 90px; overflow: auto; margin: 0 12px 12px; padding: 8px 12px; font: 13px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.konsol .err { color: var(--err); }
.konsol .info { color: var(--faint); }
.konsol .hint { color: var(--sky); }
.konsol a { color: inherit; text-decoration: underline dotted; cursor: pointer; }

/* ---------- panduan ---------- */
.mini { background: transparent; border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 8px; font-size: 12px; cursor: pointer; color: var(--muted); }
dialog { width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(2, 6, 23, .7); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-body { padding: 4px 18px 18px; }
.dlg-body h3 { margin: 18px 0 6px; font-size: 15px; color: var(--accent-2); }
.dlg-body p { margin: 6px 0; color: #cbd5e1; }
.dlg-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dlg-body td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dlg-body td:first-child { font-family: var(--mono); color: var(--sky); white-space: nowrap; }
.dlg-body code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; color: var(--accent-2); font-family: var(--mono); }
.dlg-body pre { background: var(--panel-2); padding: 10px 12px; border-radius: 8px; font: 13px/1.5 var(--mono); overflow: auto; }
details.contoh { border: 1px solid var(--line-2); border-radius: 8px; margin: 8px 0; background: var(--panel-2); }
details.contoh summary { cursor: pointer; padding: 8px 12px; font-weight: 600; }
details.contoh[open] summary { border-bottom: 1px solid var(--line); }
details.contoh .contoh-file { padding: 10px 12px 0; font-family: var(--mono); font-size: 13px; }
details.contoh .contoh-file span { color: var(--muted); font-family: var(--sans); font-size: 12px; margin-left: 8px; }
details.contoh pre { margin: 6px 12px 10px; background: var(--panel); }
.swatch { display: inline-flex; align-items: center; gap: 5px; margin: 2px 10px 2px 0; font-family: var(--mono); font-size: 12.5px; }
.swatch i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgba(255,255,255,.25); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
