/* Mulhem virtual lab — same tokens as the platform (indigo brand, amber spark) */
:root {
  --bg: #F5F5FA; --surface: #FFFFFF; --surface2: #F8F8FC; --border: #E4E3EE; --text: #1B1A33; --muted: #5E5D78;
  --brand: #4B3DD6; --brandSoft: #ECEAFC; --spark: #F2A516; --ok: #2F7A45; --okSoft: #E6F3EA; --bad: #B4382E; --badSoft: #FBE9E7;
  --warn: #8F5B00; --warnSoft: #FDF3DC; --code: #15142A; --codeText: #E0DEF5;
  --f: "IBM Plex Sans Arabic", Tahoma, sans-serif; --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #100F1F; --surface: #18172B; --surface2: #1F1E36; --border: #2E2C4A; --text: #ECEBF7; --muted: #A09EBE;
    --brand: #A69DFF; --brandSoft: #2A2654; --okSoft: #16352A; --ok: #6CC98A; --badSoft: #3B1D1A; --bad: #F08A7E; --warnSoft: #3A2E12; --warn: #E9B54F; color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--f); font-size: 14px; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-size: 17px; }
.brand img { border-radius: 9px; }
.sep { width: 1px; height: 24px; background: var(--border); }
.top h1 { margin: 0; font-size: 16px; font-weight: 700; }
.tabs { display: flex; gap: 4px; margin-inline-start: auto; padding: 4px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--border); }
.tabs button { border: 0; background: transparent; color: var(--muted); font-weight: 600; padding: 7px 14px; border-radius: 9px; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.lang { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 7px 12px; font-weight: 600; }

main { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; padding: 16px; max-width: 1500px; margin: 0 auto; }
@media (max-width: 960px) { main { grid-template-columns: 1fr; } .top h1, .sep { display: none; } }

.challenges { min-width: 0; }
.challenges h2 { font-size: 15px; margin: 4px 4px 10px; }
.challenges ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 960px) { .challenges ol { flex-direction: row; overflow-x: auto; padding-bottom: 4px; } .challenges li { min-width: 200px; } }
.challenges li button { width: 100%; text-align: start; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.challenges li button[aria-current="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.challenges li b { font-size: 14px; }
.challenges li small { color: var(--muted); display: flex; gap: 6px; align-items: center; }
.done-mark { color: var(--ok); font-weight: 700; }

.pane { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.goal { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 16px; background: var(--brandSoft); }
.goal b { font-size: 16px; }
.goal span { color: var(--text); line-height: 1.7; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.tool { border: 1px solid var(--border); background: var(--surface2); color: var(--text); border-radius: 10px; padding: 7px 11px; font-weight: 600; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.tool[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.tool svg { width: 22px; height: 22px; }
.colors { display: inline-flex; gap: 4px; padding-inline-start: 4px; }
.colors button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.colors button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--brand); }
.run { margin-inline-start: auto; border: 0; background: var(--brand); color: #fff; border-radius: 12px; padding: 10px 18px; font-weight: 700; font-size: 15px; }
.run.stop { background: var(--bad); }
.hint { margin: 0; color: var(--muted); }

.board-wrap { direction: ltr; border: 1px solid var(--border); border-radius: 18px; background: repeating-linear-gradient(0deg, transparent 0 23px, color-mix(in srgb, var(--border) 45%, transparent) 23px 24px), var(--surface); overflow-x: auto; touch-action: manipulation; }
#board { display: block; width: 100%; min-width: 760px; height: auto; direction: ltr; user-select: none; }
#board .hole { fill: #9C9483; pointer-events: none; }
#board .hole-hit { fill: transparent; cursor: pointer; }
#board .hole-hit:hover + .hole, #board .hole.hot { fill: var(--brand); }
#board .strip-hi { fill: color-mix(in srgb, var(--brand) 18%, transparent); pointer-events: none; }
#board .pin-hit { fill: transparent; cursor: pointer; }
#board .pin.hot { fill: #FFB21E; }
#board .part { cursor: pointer; }
#board .part.sel .outline, #board .wire.sel .core { stroke: #FFB21E; }
#board .part.bad .outline { stroke: #E5484D; stroke-width: 3; }
#board .wire { cursor: pointer; }
#board .ghost-ok { fill: #2F7A45; opacity: .8; }
#board .ghost-bad { fill: #E5484D; opacity: .8; }
#board .badge { font: 700 12px var(--f); }
#board text { font-family: var(--mono); }

.below { display: flex; flex-wrap: wrap; gap: 12px; }
.below > .panel { flex: 1 1 320px; min-width: 0; }
.panel { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 14px 16px; }
.panel h3 { margin: 0 0 8px; font-size: 14px; }
.below > .code { flex-basis: 100%; }
.code summary { font-weight: 700; cursor: pointer; }
pre { margin: 8px 0 0; padding: 12px; border-radius: 12px; background: var(--code); color: var(--codeText); font: 500 12.5px/1.65 var(--mono); overflow-x: auto; text-align: left; }
pre .c { color: #8F8CB8; }
pre .k { color: #FFB21E; }
#result .verdict { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; }
#result .verdict.ok { background: var(--okSoft); }
#result .verdict.bad { background: var(--badSoft); }
#result .verdict b { display: block; }
#result ol { margin: 8px 0 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.7; }
#result li.warn { color: var(--warn); }
#result li[data-part] { cursor: help; }
#controls-panel label, #controls-panel > div { display: flex; flex-direction: column; gap: 6px; font-weight: 600; margin-bottom: 8px; }
#serial { max-height: 120px; }

.stage { position: relative; border: 1px solid var(--border); border-radius: 18px; overflow: hidden; background: radial-gradient(ellipse at 50% 30%, #2C2770 0%, #15132E 80%); aspect-ratio: 16 / 9; min-height: 300px; }
#three { display: block; width: 100%; height: 100%; }
.hint3d { position: absolute; bottom: 8px; inset-inline-start: 12px; margin: 0; color: #CFCBF5; font-size: 12px; }
.steps { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.step-head { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.bar { flex: 1; height: 6px; border-radius: 6px; background: var(--surface2); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--brand); transition: width .3s; }
#step-text { margin: 0; font-size: 16px; line-height: 1.8; min-height: 2.6em; }
.step-nav { display: flex; gap: 8px; flex-wrap: wrap; }

/* names on hover, editable wire bends, the hold-to-move button */
.tip { position: fixed; z-index: 50; max-width: 340px; padding: 6px 10px; border-radius: 8px; background: #16131F; color: #fff; font-size: 12.5px; line-height: 1.5; pointer-events: none; box-shadow: 0 6px 20px #0004; }
.bend { fill: #fff; stroke: #5B4CE0; stroke-width: 2.5; cursor: move; }
.foot { cursor: help; }
.foot:hover { fill: #FFD21F; }
.tool.hold { width: 100%; justify-content: center; padding: 10px; }
.tool.hold[aria-pressed="true"] { background: #5B4CE0; color: #fff; }
#dist-wrap output { font-variant-numeric: tabular-nums; min-width: 56px; }
.goal .why { display: block; flex-basis: 100%; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
