:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e2e5ea;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --err: #c92a2a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
#app { display: grid; grid-template-columns: 340px 1fr; height: 100vh; }

/* ---------- sidebar ---------- */
#side {
  overflow-y: auto;
  padding: 14px;
  border-right: 1px solid var(--line);
  background: #fafbfc;
  display: flex; flex-direction: column; gap: 12px;
}
h1 { font-size: 19px; margin: 0; }
h2 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; color: #374151; }
h2 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.muted { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row select { flex: 1; min-width: 0; }

button {
  font: inherit; cursor: pointer;
  border: 1px solid #cfd4dc; background: #fff; color: var(--ink);
  border-radius: 7px; padding: 6px 11px;
}
button:hover { background: #f1f3f6; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { background: #1d4fd0; }
button.ghost { background: transparent; }
button.small { font-size: 12px; padding: 4px 9px; margin-top: 8px; }
select, input[type=text], input[type=number] {
  font: inherit; width: 100%;
  border: 1px solid #cfd4dc; border-radius: 7px; padding: 5px 7px; background: #fff;
}
.fld { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #4b5563; }
.fld.full { grid-column: 1 / -1; }
#fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.err { color: var(--err); font-size: 12px; min-height: 0; margin-top: 6px; }
.err:empty { display: none; }
.chk { display: flex; gap: 8px; align-items: center; margin: 4px 0; cursor: pointer; }

#elList { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
#elList li {
  display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: start;
  padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px;
}
#elList li.hidden-el { opacity: .5; }
#elList li.result-el .el-name::after { content: ' · doar rezultatul'; font-weight: 400; color: #6b7280; font-size: 11px; }
#elList li.editing { outline: 2px solid var(--accent); }
.sw { width: 12px; height: 12px; border-radius: 3px; margin-top: 3px; }
.el-name { font-weight: 600; }
.el-type { color: var(--muted); font-size: 12px; }
.el-info { font-size: 12px; color: #374151; word-break: break-word; }
.el-info.bad { color: var(--err); }
.el-btns { display: flex; gap: 2px; }
.el-btns button { padding: 2px 6px; font-size: 13px; border-color: transparent; background: transparent; }
.el-btns button:hover { background: #eef1f5; }

/* ---------- main ---------- */
main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.ctrls { display: flex; gap: 4px; }
.ctrls button { min-width: 40px; font-size: 15px; }
.ctrls button.play { min-width: 54px; }
.speed { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #4b5563; }
#speedVal { width: 34px; }
#progress { flex: 1; min-width: 120px; height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
#progBar { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
#stepCount { font-variant-numeric: tabular-nums; color: #4b5563; font-size: 13px; }
#caption {
  padding: 9px 16px; min-height: 44px; background: #fffbea; border-bottom: 1px solid #f1e3a6;
  font-size: 14.5px;
}
.tag { display: inline-block; color: #fff; border-radius: 5px; padding: 0 6px; margin-right: 6px; font-weight: 600; font-size: 12px; }

#views { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; min-height: 0; }
.view {
  position: relative; display: flex; flex-direction: column; min-height: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.vhead { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line); gap: 8px; }
.vtitle { font-weight: 600; }
.vbtns { display: flex; gap: 4px; flex-wrap: wrap; }
.vbtns button { font-size: 12px; padding: 3px 8px; }
canvas { flex: 1; width: 100%; min-height: 0; display: block; touch-action: none; cursor: grab; }
canvas:active { cursor: grabbing; }
.hint { position: absolute; bottom: 6px; left: 10px; font-size: 11px; color: #9aa1ab; pointer-events: none; }

#stepsPanel { height: 190px; overflow-y: auto; padding: 8px 14px 10px; background: var(--panel); border-top: 1px solid var(--line); }
#stepList { margin: 0; padding-left: 26px; }
#stepList li { padding: 3px 6px; border-radius: 6px; cursor: pointer; color: #9ca3af; }
#stepList li.done { color: var(--ink); }
#stepList li.cur { background: #e8efff; color: var(--ink); }
#stepList li:hover { background: #f1f3f6; }
#stepList .tag { font-size: 11px; }
#stepList .step-eye { float: right; padding: 0 4px; margin-left: 6px; font-size: 12px; border: 0; background: transparent; opacity: .35; cursor: pointer; }
#stepList li:hover .step-eye { opacity: .9; }
#stepList li.step-hidden { text-decoration: line-through; opacity: .55; }
#stepList li.step-hidden .step-eye { opacity: .9; filter: grayscale(1); }

@media (max-width: 1100px) {
  #app { grid-template-columns: 1fr; height: auto; }
  #side { border-right: 0; }
  #views { grid-template-columns: 1fr; }
  .view { height: 70vh; }
}

/* încorporată într-o lecție pe eduspaces.ro (?embed=1): desenele primele, apoi pașii și exemplele;
   construcțiile proprii se fac cu aplicația deschisă pe tot ecranul */
html:has(body.embed), body.embed { height: auto; }
body.embed #app { grid-template-columns: 1fr; height: auto; }
body.embed main { order: 1; }
body.embed #side { order: 2; border-right: 0; }
body.embed #side header, body.embed #side section:nth-of-type(2), body.embed #side section:nth-of-type(3) { display: none; }
body.embed #views { grid-template-columns: 1fr; }
body.embed .view { height: 420px; }
.el-btns button.off { opacity: .35; text-decoration: line-through; }
.legend { margin: 6px 0 0; font-size: 12.5px; color: #555; }
