/* RuangIoT Wiring Pro (G2–G4) — loaded only when IOTWIN_REALISTIC_ASSETS is on.
 * Parts are drawn by Hardware Art v2 at 0.1" = 18 px (model units); the node is scaled by the editor zoom.
 * Wire colour is a reading aid only — it never defines a net. */
.wp-on .vl-canvas > svg#vlWires { z-index: 5; overflow: visible; }
.wp-on #vlNodes { z-index: 2; }

/* ---- art nodes ------------------------------------------------------------------------------ */
.wp-on .vl-node.is-art { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none !important; min-height: 0; transform-origin: 0 0; overflow: visible; cursor: grab; }
.wp-on .vl-node.is-art:active { cursor: grabbing; }
.wp-on .vl-node.is-art .wp-art, .wp-on .vl-node.is-art .wp-art > svg { display: block; width: 100%; height: 100%; pointer-events: none; }
/* Isolate artwork from the shell's icon rule (.iw-body svg { fill:none; stroke:currentColor; stroke-width:1.8 }),
   which otherwise outlines every unstroked element (holes, silkscreen text) in dark 1.8 px. Restore SVG defaults. */
.wp-on .vl-node.is-art .wp-art > svg { fill: #000; stroke: none; stroke-width: 1; stroke-linecap: butt; stroke-linejoin: miter; flex: none; }
.wp-on .vl-node.is-art .wp-art > svg { overflow: visible; filter: drop-shadow(0 2px 2.5px rgba(15, 23, 42, .28)); }
.wp-on .vl-node.is-art[data-art^="breadboard"] .wp-art > svg { filter: drop-shadow(0 3px 6px rgba(15, 23, 42, .16)); }
/* R2D-2: gambar meja dari render model 3D — render = lapisan dasar (berbayang seperti artwork); dari artwork hanya lapisan
   hidup [data-dyn] (lampu, pendar, segmen, lampu latar, kanvas layar) yang tampil. Elemen tersembunyi tetap punya kotak
   batas → kendali (controlAt) & pin tidak berubah. */
/* render di bawah (z −1 dalam konteks tumpukan .wp-art) — svg (alur biasa) & kanvas layar (absolut) tetap di atasnya */
.wp-on .vl-node.is-art .wp-art.has-render { position: relative; isolation: isolate; }
.wp-on .vl-node.is-art .wp-art.has-render > .wp-render { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; user-select: none; -webkit-user-drag: none; filter: drop-shadow(0 2px 2.5px rgba(15, 23, 42, .28)); }
.wp-on .vl-node.is-art .wp-art.has-render > svg { filter: none; }
.wp-on .vl-node.is-art .wp-art.has-render > svg * { visibility: hidden; }
.wp-on .vl-node.is-art .wp-art.has-render > svg [data-dyn], .wp-on .vl-node.is-art .wp-art.has-render > svg [data-dyn] * { visibility: visible; }
/* kendali (.rs-ctl, pointer-events: all) tetap bisa diklik walau tersembunyi; saat disorot gambar kendalinya tampil samar
   (dengan pendar sorot bawaan) sebagai petunjuk "bagian ini bisa ditekan/diputar" */
.wp-on .vl-node.is-art .wp-art.has-render > svg .rs-ctl:hover, .wp-on .vl-node.is-art .wp-art.has-render > svg .rs-ctl:hover * { visibility: visible; }
.wp-on .vl-node.is-art .wp-art.has-render > svg .rs-ctl:hover { opacity: .45; }
/* R2D-3: bagian bergerak = sprite render di dalam grup [data-dyn] (ikut putar/geser update()); gambar vektor grup itu &
   grup pendampingnya (bayangan, kilap, tutup) disembunyikan. Kelas wp-sprite-host hanya dipasang editor bila sprite-nya benar
   ditaruh (tanpa :has(), supaya peramban lama — mis. Firefox ESR 115 — juga tidak menggambar dua tanduk/kenop). */
.wp-on .vl-node.is-art .wp-art.has-render > svg [data-dyn].wp-sprite-host :not(.wp-sprite) { visibility: hidden; }
.wp-on .vl-node.is-art .wp-art.has-render > svg .wp-sprite { visibility: visible; pointer-events: none; }
.wp-on .vl-node.is-art .wp-art.has-render > svg .wp-dyn-off, .wp-on .vl-node.is-art .wp-art.has-render > svg .wp-dyn-off * { visibility: hidden !important; }
.wp-on .vl-node.is-art.is-selected { outline: 2px dashed #2f6fde; outline-offset: 5px; }
.wp-on .vl-node.is-art.is-locked { opacity: .85; }
.wp-on .wp-label { position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%); display: none; white-space: nowrap; padding: 3px 7px; border-radius: 5px; background: rgba(15, 23, 42, .88); color: #fff; font: 600 9px/1.3 Inter, system-ui, sans-serif; pointer-events: none; z-index: 6; }
.wp-on .wp-label small { display: block; font-weight: 500; opacity: .8; }
.wp-on .vl-node.is-art:hover .wp-label, .wp-on .vl-node.is-art.is-selected .wp-label { display: block; }

/* ---- pin anchors: a small ring exactly on the lead end / header pad ------------------------- */
.wp-on .vl-pin.is-anchor.wp-pin { width: 9px; height: 9px; border: 1.5px solid rgba(255, 255, 255, .95); background: rgba(47, 111, 222, .0); box-shadow: 0 0 0 1px rgba(15, 23, 42, .55); outline: 0; cursor: crosshair; z-index: 4; }
.wp-on .vl-pin.is-anchor.wp-pin:hover, .wp-on .vl-pin.is-anchor.wp-pin:focus-visible, .wp-on .vl-pin.is-anchor.wp-pin.is-pending { width: 12px; height: 12px; background: #ffd447; box-shadow: 0 0 0 2px #b45309; outline: 0; }
.wp-on .vl-pin.is-anchor.wp-pin span { bottom: calc(100% + 5px); font-size: 9px; }
/* breadboard holes: invisible hit targets on top of the drawn holes */
.wp-on .vl-pin.is-anchor.wp-hole-pin { width: 13px; height: 13px; border: 0; background: transparent; box-shadow: none; border-radius: 2px; }
.wp-on .vl-pin.is-anchor.wp-hole-pin:hover, .wp-on .vl-pin.is-anchor.wp-hole-pin.is-pending { width: 13px; height: 13px; background: rgba(255, 212, 71, .55); box-shadow: 0 0 0 1.5px #b45309; }
.wp-on .vl-pin.is-anchor.wp-hole-pin span { display: none !important; }
/* used holes turn green; hovering a hole lights its conductive strip/rail segment */
.wp-on .vl-node.is-art [data-hole].wp-used { fill: #1f9d55; }
.wp-on .vl-node.is-art [data-hole].wp-strip { fill: #2f6fde; }
.wp-on .vl-node.is-art [data-hole].wp-strip.wp-used { fill: #0f766e; }

/* ---- wires -------------------------------------------------------------------------------- */
.wp-on #vlWires .wp-wire { cursor: pointer; }
.wp-on #vlWires .wp-wire path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.wp-on #vlWires .wp-halo { stroke: transparent; stroke-width: 12; pointer-events: stroke; }
.wp-on #vlWires .wp-outline { stroke-width: 5.4; pointer-events: none; }
.wp-on #vlWires .wp-core { stroke-width: 3.6; pointer-events: none; }
.wp-on #vlWires .wp-shine { stroke: rgba(255, 255, 255, .38); stroke-width: 1; transform: translate(-.6px, -.6px); pointer-events: none; }
.wp-on #vlWires .wp-end { pointer-events: none; stroke: rgba(255, 255, 255, .7); stroke-width: .8; }
.wp-on #vlWires .wp-wire:hover .wp-halo { stroke: rgba(47, 111, 222, .16); }
.wp-on #vlWires .wp-wire.is-selected .wp-halo { stroke: rgba(47, 111, 222, .28); }
.wp-on #vlWires .wp-wire.is-net .wp-halo { stroke: rgba(255, 196, 0, .4); }
.wp-on #vlWires .wp-handle { fill: #fff; stroke: #2f6fde; stroke-width: 2; cursor: move; pointer-events: all; }
.wp-on #vlWires .wp-endhandle { fill: rgba(255, 255, 255, .85); stroke: #b45309; stroke-width: 2; cursor: crosshair; pointer-events: all; }
.wp-on #vlWires .wp-preview { fill: none; stroke: #2f6fde; stroke-width: 3; stroke-dasharray: 6 5; stroke-linecap: round; pointer-events: none; }
.wp-on #vlWires .wp-preview-end { fill: #ffd447; stroke: #b45309; stroke-width: 1.5; pointer-events: none; }
/* Uji Pemula (13 Nov): circuit-views.css memberi SEMUA path kabel "pointer-events: stroke" dengan selektor dua id
   (#vlCanvas #vlWires path) yang mengalahkan aturan di atas. Akibatnya garis pratinjau kabel — ujungnya selalu tepat di
   bawah kursor — menangkap klik ke pin tujuan (kabel "hantu" tidak bisa selesai/batal, GND kanan ESP32 seolah menolak), dan
   inti/garis tepi kabel menutupi pin. Hanya "halo" kabel yang boleh menerima klik; saat kabel sedang ditarik atau di mode
   Kabel, kabel lain tidak menerima klik sama sekali (pin selalu menang). */
#vlCanvas #vlWires .wp-preview, #vlCanvas #vlWires .wp-preview-end,
#vlCanvas #vlWires .wp-outline, #vlCanvas #vlWires .wp-core, #vlCanvas #vlWires .wp-shine, #vlCanvas #vlWires .wp-end { pointer-events: none; }
#vlCanvas.is-pin-pending #vlWires *, .st-app[data-tool="wire"] #vlCanvas #vlWires * { pointer-events: none !important; }
#vlCanvas.is-pin-pending { cursor: crosshair; }
.wp-on #vlWires.wp-passthrough, .wp-on #vlWires.wp-passthrough * { pointer-events: none !important; }

/* ---- net highlight (selection lives in circuit-views; we only style whole wires) ------------- */
.wp-on #vlCanvas.cv-dim #vlWires .wp-wire path { opacity: 1; }
.wp-on #vlCanvas.cv-dim #vlWires .wp-wire:not(:has(.cv-hl)) { opacity: .25; }
.wp-on #vlCanvas #vlWires .wp-wire:has(.wp-core.cv-hl) .wp-halo { stroke: rgba(245, 158, 11, .5); }

/* ---- wire toolbar + toast ------------------------------------------------------------------- */
.wp-toolbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 20; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; max-width: calc(100% - 24px); padding: 6px 8px; border: 1px solid #d7e1ef; border-radius: 10px; background: #fff; box-shadow: 0 8px 24px rgba(16, 42, 86, .16); font: 600 12px/1.2 Inter, system-ui, sans-serif; color: #17243a; }
.wp-toolbar[hidden] { display: none; }
.wp-toolbar .wp-tb-title { margin-right: 4px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; color: #334155; }
.wp-toolbar .wp-swatch { width: 20px; height: 20px; padding: 0; border: 2px solid #fff; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px #94a3b8; cursor: pointer; }
.wp-toolbar .wp-swatch.is-active { box-shadow: 0 0 0 2px #2f6fde; }
.wp-toolbar button:not(.wp-swatch) { border: 1px solid #d7e1ef; border-radius: 7px; background: #fff; padding: 5px 9px; font: inherit; cursor: pointer; }
.wp-toolbar button.is-danger { color: #b91c1c; border-color: #fecaca; }
.wp-toolbar .wp-field { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.wp-toolbar select, .wp-toolbar input[type=number] { border: 1px solid #cbd5e1; border-radius: 7px; padding: 4px 6px; font: inherit; background: #fff; }
.wp-toolbar input[type=number] { width: 92px; }
.wp-toolbar .wp-tb-note { font-weight: 500; font-size: 11px; color: #64748b; }
.wp-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 9999; max-width: min(560px, calc(100vw - 32px)); padding: 10px 14px; border-radius: 10px; background: #0f172a; color: #fff; font: 500 13px/1.4 Inter, system-ui, sans-serif; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }

@media (max-width: 620px) {
  .wp-toolbar { top: 6px; padding: 5px; gap: 4px; }
  .wp-toolbar .wp-tb-title { flex-basis: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .wp-on #vlWires .wp-wire.is-selected .wp-core { stroke-dasharray: none; }
}

/* ---- template panel (G6) ------------------------------------------------------------------- */
.wp-modal { position: fixed; inset: 0; z-index: 9998; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 42, .5); }
.wp-modal-card { width: min(760px, 100%); max-height: min(86vh, 900px); overflow: auto; border-radius: 14px; background: #fff; color: #17243a; box-shadow: 0 24px 60px rgba(0, 0, 0, .3); font: 14px/1.45 Inter, system-ui, sans-serif; }
.wp-modal-card header { position: sticky; top: 0; display: flex; justify-content: space-between; gap: 12px; padding: 16px 18px 10px; background: #fff; border-bottom: 1px solid #e5eaf2; }
.wp-modal-card h3 { margin: 0; font-size: 17px; color: #0f2a5f; }
.wp-modal-card header p { margin: 4px 0 0; font-size: 12px; color: #64748b; }
.wp-x { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: #475569; }
.wp-tpl-list { padding: 12px 18px 18px; display: grid; gap: 10px; }
.wp-tpl { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; padding: 12px 14px; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fbff; }
.wp-tpl strong { color: #0f2a5f; }
.wp-tpl p { margin: 3px 0 6px; font-size: 12.5px; color: #475569; }
.wp-tpl table { border-collapse: collapse; font-size: 11.5px; }
.wp-tpl th { padding: 1px 10px 1px 0; text-align: left; font: 600 11px ui-monospace, SFMono-Regular, Consolas, monospace; color: #1e3a8a; white-space: nowrap; }
.wp-tpl td { padding: 1px 0; color: #334155; }
.wp-tpl-load { flex: 0 0 auto; border: 0; border-radius: 8px; padding: 8px 16px; background: #1769ff; color: #fff; font-weight: 700; cursor: pointer; }
.wp-tpl-load:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
.wp-tpl-libs { margin: 6px 0 0 !important; font-size: 11.5px !important; color: #475569; }
.wp-tpl-libs span { font-weight: 700; color: #1e3a8a; }
/* Tema gelap: panel template mengikuti preferensi "ri-theme" (html[data-theme=dark] / html.ri-dark). */
html[data-theme="dark"] .wp-modal-card, html.ri-dark .wp-modal-card { background: #0f172a; color: #e2e8f0; box-shadow: 0 24px 60px rgba(0, 0, 0, .55); }
html[data-theme="dark"] .wp-modal-card header, html.ri-dark .wp-modal-card header { background: #0f172a; border-bottom-color: #1e293b; }
html[data-theme="dark"] .wp-modal-card h3, html.ri-dark .wp-modal-card h3 { color: #f1f5f9; }
html[data-theme="dark"] .wp-modal-card header p, html.ri-dark .wp-modal-card header p { color: #94a3b8; }
html[data-theme="dark"] .wp-tpl, html.ri-dark .wp-tpl { background: #111c33; border-color: #22314d; }
html[data-theme="dark"] .wp-tpl strong, html.ri-dark .wp-tpl strong { color: #e2e8f0; }
html[data-theme="dark"] .wp-tpl p, html.ri-dark .wp-tpl p, html[data-theme="dark"] .wp-tpl td, html.ri-dark .wp-tpl td, html[data-theme="dark"] .wp-tpl-libs, html.ri-dark .wp-tpl-libs { color: #cbd5e1; }
html[data-theme="dark"] .wp-tpl th, html.ri-dark .wp-tpl th, html[data-theme="dark"] .wp-tpl-libs span, html.ri-dark .wp-tpl-libs span { color: #93c5fd; }
html[data-theme="dark"] .wp-x, html.ri-dark .wp-x { color: #cbd5e1; }
@media (max-width: 620px) { .wp-tpl { flex-direction: column; } .wp-tpl-load { align-self: stretch; } }
/* Uji Pemula dok. 1 (Iterasi 14): gambar mini + tingkat + durasi + tujuan belajar di galeri template */
.wp-tpl > div { flex: 1 1 auto; min-width: 0; }
.wp-tpl-thumb { position: relative; flex: 0 0 136px; width: 136px; aspect-ratio: 800 / 520; overflow: hidden; border-radius: 8px; background: #eef2f7; }
.wp-tpl-thumb[hidden] { display: none; }
.wp-tpl-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
html[data-theme="dark"] .wp-tpl-thumb .st-ex-light, html:not([data-theme="dark"]) .wp-tpl-thumb .st-ex-dark { display: none; }
.wp-tpl-meta { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }
.wp-tpl-meta span { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px; background: #eef2f7; color: #334155; font: 600 11px/1 system-ui, sans-serif; }
.wp-tpl-meta span[data-level="pemula"] { background: #e6f6f4; color: #0f766e; font-weight: 700; }
.wp-tpl-meta span[data-level="menengah"] { background: #fef3c7; color: #92400e; font-weight: 700; }
.wp-tpl-meta span[data-level="lanjutan"] { background: #fef2f2; color: #b91c1c; font-weight: 700; }
.wp-tpl .wp-tpl-goal { color: #334155; }
@media (max-width: 640px) { .wp-tpl { flex-wrap: wrap; } .wp-tpl-thumb { flex-basis: 100%; width: 100%; } }
html[data-theme="dark"] .wp-tpl-meta span, html.ri-dark .wp-tpl-meta span { background: #1e293b; color: #cbd5e1; }
html[data-theme="dark"] .wp-tpl-meta span[data-level="pemula"], html.ri-dark .wp-tpl-meta span[data-level="pemula"] { background: #0e2c2b; color: #5eead4; }
html[data-theme="dark"] .wp-tpl-meta span[data-level="menengah"], html.ri-dark .wp-tpl-meta span[data-level="menengah"] { background: #3a2a0b; color: #fbbf24; }
html[data-theme="dark"] .wp-tpl-meta span[data-level="lanjutan"], html.ri-dark .wp-tpl-meta span[data-level="lanjutan"] { background: #3b1219; color: #fca5a5; }
html[data-theme="dark"] .wp-tpl .wp-tpl-goal, html.ri-dark .wp-tpl .wp-tpl-goal { color: #cbd5e1; }
html.ri-dark:not([data-theme]) .wp-tpl-thumb .st-ex-light { display: none; }
html.ri-dark:not([data-theme]) .wp-tpl-thumb .st-ex-dark { display: block; }
/* Uji Pemula dok. 1 (Iterasi 17): keterbacaan & aksesibilitas
   - pin terdekat dalam jangkauan magnet menyala lebih dulu (target efektif ≥ 24 px) dan namanya tampil;
   - label pin & nama komponen ≥ 10 px di layar pada zoom berapa pun dan tidak ikut terbalik/tercermin;
   - komponen yang difokus dengan papan ketik diberi cincin fokus. */
.wp-on .vl-pin.is-anchor.wp-pin.wp-magnet { width: 12px; height: 12px; background: #ffd447; box-shadow: 0 0 0 2px #b45309, 0 0 0 7px rgba(255, 212, 71, .35); }
.wp-on .vl-pin.is-anchor.wp-hole-pin.wp-magnet { width: 13px; height: 13px; background: rgba(255, 212, 71, .75); box-shadow: 0 0 0 1.5px #b45309, 0 0 0 6px rgba(255, 212, 71, .3); }
.wp-on .vl-pin.is-anchor.wp-magnet span { display: block; }
.wp-on .vl-pin.is-anchor.wp-hole-pin.wp-magnet span { display: none !important; }
.wp-on .vl-pin.is-anchor.wp-pin span { font-size: max(9px, calc(10px / var(--vl-zoom, 1))); transform: translateX(-50%) scaleX(var(--vl-flip, 1)) rotate(calc(-1 * var(--vl-rot, 0deg))); }
.wp-on .wp-label { font-size: max(9px, calc(10px / var(--vl-zoom, 1))); transform: translateX(-50%) scaleX(var(--vl-flip, 1)) rotate(calc(-1 * var(--vl-rot, 0deg))); }
.wp-on .vl-node.is-art:focus { outline: none; }
.wp-on .vl-node.is-art:focus-visible { outline: calc(2px / var(--vl-zoom, 1)) solid #2f6fde; outline-offset: calc(4px / var(--vl-zoom, 1)); border-radius: 6px; }
.wp-on .vl-node.is-art:focus-visible .wp-label { display: block; }
