/* FlowByte styles. Light theme first, then dark theme overrides. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10151c;
    --panel: #1a212b;
    --ink: #e8edf4;
    --mut: #9aa6b8;
    --line: #2e3846;
    --acc: #3f73e0;
    --hl: #ffc233;
    color-scheme: dark;
  }
}

html {
  height: 100%;
  scroll-padding-top: env(safe-area-inset-top, 0px);
}
body {
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font:
    14px/1.45 "Trebuchet MS",
    "Segoe UI",
    system-ui,
    sans-serif;
}
header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
h1 {
  font:
    700 18px/1 Georgia,
    "Times New Roman",
    serif;
  margin: 0 8px 0 0;
}
button,
select,
input {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}
button {
  cursor: pointer;
}
button:hover {
  border-color: var(--acc);
}
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 1px;
}
.pri {
  background: var(--acc);
  border-color: var(--acc);
  color: #fff;
}
.sp {
  flex: 1;
}
.mt {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 8px;
}

@keyframes bfl {
  50% {
    opacity: 0;
  }
}

@keyframes blp {
  from {
    transform: translate(0, 0);
  }
  to {
    transform: translate(var(--dx), var(--dy));
  }
}

aside > .box {
  flex-shrink: 0;
}

.anl {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  font-size: 13px;
}
.anl input {
  flex: 1;
  min-width: 0;
  padding: 0;
}
.anl b {
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#mimic .ro {
  font:
    700 9px ui-monospace,
    Menlo,
    Consolas,
    monospace;
  fill: #7cfc9a;
}
#mimic .fs {
  font:
    700 12px "Trebuchet MS",
    system-ui,
    sans-serif;
  letter-spacing: 2px;
  fill: #4a2626;
  transition: fill 0.3s;
}
#mimic .fs.on {
  fill: #ff4d4d;
}
.spinf.on {
  animation: spin 0.8s linear infinite;
}
.rain {
  animation: rn 0.7s linear infinite;
}
@keyframes rn {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(46px);
    opacity: 0.15;
  }
}
.arm {
  transition: transform calc(1.2s * var(--anim, 1)) ease-in-out;
}
.arm.on {
  transform: rotate(-80deg);
}
.on > .cpgo {
  animation: cpg 2.4s ease-in forwards;
}
@keyframes cpg {
  to {
    transform: translateX(250px);
  }
}
.dl,
.dr {
  transition: transform calc(1s * var(--anim, 1)) ease-in-out;
}
.dl.on {
  transform: translateX(-40px);
}
.dr.on {
  transform: translateX(40px);
}
.din,
.dout {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}
.on > .din {
  animation: din 2.3s ease-in-out forwards;
}
@keyframes din {
  0% {
    transform: none;
    opacity: 1;
  }
  70% {
    transform: translate(64px, -30px) scale(0.72);
    opacity: 1;
  }
  100% {
    transform: translate(64px, -34px) scale(0.66);
    opacity: 0;
  }
}
.on > .dout {
  animation: dout 2.3s ease-in-out forwards;
}
@keyframes dout {
  0% {
    transform: none;
    opacity: 1;
  }
  75% {
    transform: translate(58px, 26px) scale(1.3);
    opacity: 1;
  }
  100% {
    transform: translate(72px, 32px) scale(1.35);
    opacity: 0;
  }
}

section.box .tools {
  grid-column: 1;
  grid-row: 1/5;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  border-bottom: 0;
  border-right: 1px solid var(--line);
  gap: 6px;
}
section.box #insp {
  grid-column: 2;
  grid-row: 2;
}
section.box #cv {
  grid-column: 2;
  grid-row: 3;
  min-height: 0;
}
section.box .stb {
  grid-column: 2;
  grid-row: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-right: 8px;
}
section.box .stb #st {
  border-top: 0;
  flex: 1;
  min-width: 0;
  /* Long messages show two lines at most. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* The tip stays on one line; if the canvas is narrow it is cut short with … */
section.box #insp .tip {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Phones: the status message sits above the zoom buttons, and the long tip is hidden. */
@media (max-width: 560px) {
  section.box .stb {
    flex-wrap: wrap;
    gap: 0;
    padding: 0 8px 6px 0;
  }
  section.box .stb #st {
    flex-basis: 100%;
    padding-bottom: 4px;
  }
  section.box .stb #zm {
    margin-left: auto;
  }
  section.box #insp {
    display: none;
  }
}
#zm {
  display: flex;
  gap: 4px;
}
#zm button {
  padding: 4px 9px;
  min-width: 32px;
}
#zr {
  min-width: 58px;
  font-variant-numeric: tabular-nums;
}

.tools b {
  font-size: 11px;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 2px;
}
.tools button {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  white-space: nowrap;
}
.tools svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  flex: none;
}
@media (max-width: 860px) {
  section.box #cv {
    min-height: 420px;
  }
  section.box {
    grid-template-rows: auto auto minmax(420px, 1fr) auto;
  }
  main {
    grid-template-rows: none !important;
    grid-auto-rows: auto;
    align-content: start;
  }
  main > section.box {
    height: auto;
    min-height: 620px;
  }
  #mbox:not(.float) #mimic svg {
    max-width: 560px;
    margin: 0 auto;
  }
  .tools button span {
    display: none;
  }
}
.lt {
  font-size: 9px;
  font-weight: 700;
  fill: #17202c;
}
.lb {
  fill: #fff;
  stroke-width: 1.6;
  pointer-events: none;
  opacity: 0.95;
}
.lb.on {
  fill: #fff7cf;
  stroke-width: 2;
  opacity: 1;
}
.lb.in {
  fill: #22304a;
  stroke: #22304a;
  stroke-dasharray: none;
}
#mimic text.lt[data-i] {
  fill: #fff;
}
.lb.in.on {
  fill: #ff8a1f;
  stroke: #ff8a1f;
}
.lgd {
  display: none;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: var(--mut);
}
.lgd.on {
  display: inline-flex;
}
.lgd i {
  display: inline-block;
  width: 20px;
  height: 12px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: -1px;
}
.lgd .lo {
  background: #fff;
  border: 1.6px solid #30c46b;
}
.lgd .li {
  background: #22304a;
  border-radius: 7px;
}
circle[data-i] {
  cursor: pointer;
}

main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 10px var(--aw, 320px);
  gap: 0;
  padding: 12px;
  overflow: hidden;
}
#gut {
  cursor: col-resize;
  position: relative;
  touch-action: none;
}

@media (pointer: coarse) {
  #svg .pt {
    r: 9px;
  }
  #mimic circle.inp {
    r: 7px;
  }
  .tools button,
  #ctl button {
    min-height: 40px;
  }
}
#gut::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 30%;
  bottom: 30%;
  width: 2px;
  border-radius: 2px;
  background: var(--line);
}
#gut:hover::after,
#gut:focus-visible::after {
  background: var(--acc);
}
.mh {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
#infod {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
}
#infod::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
#infod .hh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 4px;
}
#infod h3 {
  margin: 0;
  font-size: 18px;
}
#infox {
  border: 0;
  background: none;
  font-size: 16px;
}
.infob {
  overflow: auto;
  max-height: calc(100vh - 120px);
  padding: 0 16px 16px;
  font-size: 14px;
  line-height: 1.5;
}
.infob h4 {
  margin: 14px 0 4px;
  font-size: 15px;
}
.infob p,
.infob ul {
  margin: 4px 0;
}
.infob ul {
  padding-left: 20px;
}
.infob a {
  color: var(--acc);
  font-weight: 600;
}
:root[data-theme="dark"] .infob a {
  color: #8fb4ff;
}
.infob table {
  border-collapse: collapse;
  width: 100%;
  margin: 6px 0;
  font-size: 13px;
}
.infob th,
.infob td {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
}
.hinf {
  font-size: 17px;
  line-height: 1;
  padding: 6px 10px;
  min-width: 38px;
  position: absolute;
  top: 14px;
  right: 64px;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-weight: 700;
}
#imgd {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  padding: 0;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
}
#imgd::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
#imgd .hh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
}
#imgd h3 {
  margin: 0;
  font-size: 16px;
}
#imgx {
  border: 0;
  background: none;
  font-size: 16px;
}
.imgw {
  overflow: auto;
  max-height: calc(100vh - 180px);
  padding: 0 14px 14px;
}
.imgw img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
}

body.prac:not(.prev) #con,
body.prac:not(.prev) #trace {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}
body.pflow #cbox {
  display: none !important;
}
#pbox[hidden] {
  display: none !important;
}
#pbody {
  padding: 8px 10px;
  display: grid;
  gap: 8px;
}
#flist {
  padding: 6px 8px;
  display: grid;
  gap: 8px;
  max-height: 30vh;
  overflow: auto;
}
.fi {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.fh {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.fn {
  flex: 1;
  border: 0;
  background: transparent;
  font:
    600 12.5px ui-monospace,
    Menlo,
    Consolas,
    monospace;
  padding: 5px 8px;
  color: var(--ink);
}
.fx {
  border: 0;
  background: none;
  padding: 2px 8px;
  color: var(--mut);
}
.fi textarea {
  width: 100%;
  box-sizing: border-box;
  border: 0;
  border-radius: 0;
  font:
    12.5px/1.45 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  padding: 6px 8px;
  resize: vertical;
  background: var(--panel);
  color: var(--ink);
}
#psel {
  width: 100%;
  font-size: 13px;
}
.pcode {
  margin: 0;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
  font:
    13px/1.9 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  white-space: pre;
  overflow: auto;
}
.pcode .ln {
  display: inline-block;
  width: 22px;
  color: var(--mut);
  user-select: none;
}
#pgap {
  font: inherit;
  width: calc(100% - 60px);
  min-width: 180px;
  padding: 2px 6px;
}
.perr {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 13px;
  align-items: center;
}
.perr .grow {
  flex: 1;
  display: flex;
  gap: 6px;
  align-items: center;
}
.perr .grow input {
  flex: 1;
  min-width: 140px;
  font:
    13px ui-monospace,
    Menlo,
    Consolas,
    monospace;
}
#pline {
  width: 60px;
}
.pq {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}
#pans {
  width: 100%;
  box-sizing: border-box;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font:
    13px/1.5 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  resize: vertical;
}
.ptw {
  overflow: auto;
  max-height: 40vh;
}

.pt th {
  background: var(--bg);
  font-weight: 700;
  padding: 3px 6px;
  border: 1px solid var(--line);
  position: sticky;
  top: 0;
}
.pt td {
  border: 1px solid var(--line);
  padding: 0;
}
.pt input {
  width: 72px;
  border: 0;
  border-radius: 0;
  padding: 4px 6px;
  font: inherit;
  background: var(--panel);
  color: var(--ink);
}
.pt input.bad {
  background: rgba(229, 72, 77, 0.16);
}
.pt input.good {
  background: rgba(31, 157, 85, 0.14);
}
.pres {
  margin: 0;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 13px;
}
.pres.ok {
  background: rgba(31, 157, 85, 0.12);
}
.pres.no {
  background: rgba(229, 72, 77, 0.1);
}
.pf {
  display: flex;
  gap: 6px;
  align-items: center;
}
#erlw {
  display: none;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
#edgrip {
  height: 12px;
  cursor: ns-resize;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--line);
}
#edgrip::after {
  content: "";
  width: 42px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}
#edgrip:hover::after,
#edgrip:focus-visible::after,
#edgrip.on::after {
  background: var(--acc);
}
#cbox.erl #erlw {
  display: flex;
}
/* "Both": Python and ERL side by side (stacked if the panel is too narrow). */
#cbox.both .codepair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  border-bottom: 1px solid var(--line);
}
#cbox.both #erlw {
  display: flex;
  border-left: 1px solid var(--line);
}
#cbox.both .ed {
  height: min(52vh, 600px);
  max-height: none;
  border-bottom: 0;
}
#cbox.both #erlv {
  height: min(52vh, 600px);
  max-height: none;
}
#cbox.both .erln {
  display: none;
}
#cbox.both.stack .codepair {
  grid-template-columns: 1fr;
}
#cbox.both.stack #erlw {
  border-left: 0;
  border-top: 1px solid var(--line);
}
#cbox.both.stack .ed,
#cbox.both.stack #erlv {
  height: min(30vh, 340px);
}
#cbox.erl .ed {
  display: none;
}
#erlv {
  margin: 0;
  padding: 10px 12px;
  font:
    13px/1.55 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  white-space: pre;
  overflow: auto;
  flex: none;
  height: min(44vh, 520px);
  min-height: 220px;
  background: var(--bg);
  color: var(--ink);
  border: 0;
  border-radius: 0;
}
.erln {
  font-size: 12px;
  margin: 0;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
}
.vsw button {
  padding: 4px 10px;
  font-size: 13px;
  white-space: nowrap;
}
#cbox .mh button,
#cbox .mt button {
  white-space: nowrap;
}
#cbox .mh {
  flex-wrap: wrap;
  row-gap: 6px;
}
#cbox .mh .vsw {
  flex: none;
}
#cbox .mt {
  justify-content: flex-start;
  gap: 8px;
}
#c2f,
#f2c {
  font-size: 12.5px;
  padding: 5px 9px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hf {
    color: #56b6c2;
  }
}
#chk {
  position: absolute;
  z-index: 30;
  right: 14px;
  top: 120px;
  width: min(360px, calc(100% - 28px));
  max-height: 60%;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
  padding: 8px 10px 10px;
}
#chk[hidden] {
  display: none;
}
#bpop {
  position: absolute;
  z-index: 41;
  width: min(320px, calc(100% - 20px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  padding: 6px 10px 10px;
}
#bpop[hidden] {
  display: none;
}
#bpop .ph {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
#bpop .ph b {
  font-size: 13px;
}
#bpop .ph button {
  padding: 2px 8px;
}
#popb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
#popb > .mut:first-child {
  display: none;
}
#popb .oo {
  width: 100%;
}
#popb .oo select {
  flex: 1;
  min-width: 0;
}
#popb textarea,
#popb .gtxi {
  width: 100%;
  min-width: 0;
  flex: 1 1 100%;
}
#popb .nl {
  flex-basis: 100%;
  height: 0;
}
/* KS3 decision pop-up: the question "Is ... ?" is the main thing; the decision type is small. */
#popb .decq {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  font-size: 16px;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, #d99a00 14%, transparent);
  border: 1px solid color-mix(in srgb, #d99a00 45%, transparent);
}
#popb .decq select,
#popb .decq input {
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
}
#popb .decq .nowrap {
  white-space: nowrap;
}
#popb .decq select {
  max-width: 140px;
}
#popb .dmode {
  flex: 1 1 100%;
  font-size: 12px;
  color: var(--mut);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
#popb select.mini {
  font-size: 12px;
  padding: 2px 6px;
  color: var(--mut);
  background: transparent;
}
#popb #idel {
  width: 100%;
  margin-top: 4px;
}
#popb input[type="text"] {
  max-width: 100%;
}
#rub {
  stroke: var(--acc);
  stroke-width: 2;
  stroke-dasharray: 5 4;
  fill: none;
  pointer-events: none;
}
#svg .nd.drop {
  filter: drop-shadow(0 0 5px var(--acc)) drop-shadow(0 0 2px var(--acc));
}
/* A block being dragged over another block: it can't be dropped there. */
#svg .nd.clash {
  opacity: 0.6;
  filter: drop-shadow(0 0 4px #d33) drop-shadow(0 0 2px #d33);
}
#ghost.clash g {
  stroke: #d33;
  fill: rgba(221, 51, 51, 0.15);
}

#chk .ch1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
#chk .ch1 b {
  font-size: 15px;
}
.chks {
  flex-basis: 100%;
  order: 3;
  font-size: 12px;
  color: var(--mut);
}
#chkx {
  border: 0;
  background: none;
  font-size: 15px;
  padding: 2px 6px;
}
#chkl {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
#chkl li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
  padding: 7px 8px;
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid var(--line);
}
#chkl li[data-id] {
  cursor: pointer;
}
#chkl li[data-id]:hover {
  border-color: var(--acc);
}
#chkl li.err {
  background: rgba(229, 72, 77, 0.08);
}
#chkl li.warn {
  background: rgba(242, 169, 0, 0.1);
}
#chkl li.tip {
  background: rgba(42, 98, 214, 0.07);
}
#chkl li.ok {
  background: rgba(31, 157, 85, 0.1);
  border-color: #1f9d55;
}
#chkl i {
  font-style: normal;
  font-size: 15px;
  line-height: 1.2;
}
#chkl small {
  display: block;
  color: var(--acc);
  font-weight: 600;
  margin-top: 2px;
}
.nd.bad > rect,
.nd.bad > polygon {
  stroke: #e5484d !important;
  stroke-width: 3 !important;
  stroke-dasharray: 6 3;
}
section.box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  position: relative;
}
#chbox .mh b {
  flex: none;
}
#cht {
  flex: none;
  width: 30px;
  padding: 4px 0;
  font-weight: 700;
}

#chl {
  padding: 8px;
  display: grid;
  gap: 8px;
}
#chl[hidden] {
  display: none;
}
.cht {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 3px;
  background: var(--bg, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
}
.cht button {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 4px !important;
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--mut);
  cursor: pointer;
}
.cht button span {
  font-weight: 500;
  font-size: 11.5px;
  opacity: 0.8;
}
.cht button.on {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.chs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chc.dn {
  background: #30c46b;
  border-color: #30c46b;
  color: #fff;
}

.chx {
  font-size: 12px;
  color: var(--mut);
  margin-left: 4px;
}

#chl .bt.bgt {
  background: #e5484d;
}
.chlb {
  justify-self: start;
  font-size: 12.5px;
  padding: 5px 10px;
}

.cth {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.chcard .chh {
  color: var(--mut);
  background: rgba(255, 204, 26, 0.12);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12.5px;
}
.chcard .chh[hidden] {
  display: none;
}

.chhb {
  background: none;
  border: 0;
  color: var(--acc);
  font-weight: 600;
  font-size: 12.5px;
  padding: 2px 0;
  cursor: pointer;
}
.chd {
  font-size: 12.5px;
  padding: 5px 10px;
}
.chd.on {
  background: #30c46b;
  border-color: #30c46b;
  color: #fff;
}
.chcard .chr {
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12.5px;
}
.chf button {
  white-space: nowrap;
}

.chta {
  background: none;
  border: 0;
  color: var(--mut);
  font-size: 11.5px;
  padding: 2px 0;
  cursor: pointer;
  text-decoration: underline;
}
.tcode {
  display: flex;
  gap: 6px;
}
.tcode input {
  flex: 1;
  min-width: 0;
}
.chn {
  display: inline-block;
  margin-left: 4px;
  border: 0;
  background: none;
  color: var(--acc);
  font-weight: 700;
  font-size: 12.5px;
  padding: 0;
  cursor: pointer;
}
.chcard .chr.ok {
  background: rgba(31, 157, 85, 0.12);
  color: var(--ink);
}
.chcard .chr.no {
  background: rgba(229, 72, 77, 0.1);
  color: var(--ink);
}
#chl .lv {
  font-size: 11px;
  color: #e0a100;
  letter-spacing: 1px;
}
#chl .bt {
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  background: #8a5cf6;
  border-radius: 6px;
  padding: 1px 6px;
}
#vlist .vr {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
}
#vlist input {
  min-width: 0;
}
.vn {
  font-weight: 700;
}
#vlist .vr button {
  margin-left: auto;
}
.float {
  position: fixed;
  z-index: 40;
  width: var(--fw, 360px);
  max-height: calc(100vh - 16px);
  overflow: auto;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.35);
}
.float .mh {
  cursor: move;
  touch-action: none;
  user-select: none;
}
#rzl {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nesw-resize;
  touch-action: none;
  background: linear-gradient(
    225deg,
    transparent 55%,
    var(--mut) 55% 62%,
    transparent 62% 72%,
    var(--mut) 72% 79%,
    transparent 79%
  );
}
#rzl[hidden],
#rz[hidden] {
  display: none;
}
#rz {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  touch-action: none;
  background: linear-gradient(
    135deg,
    transparent 55%,
    var(--mut) 55% 62%,
    transparent 62% 72%,
    var(--mut) 72% 79%,
    transparent 79%
  );
}
.box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
#insp {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  min-height: 30px;
}
.mut {
  color: var(--mut);
}
.oo {
  display: inline-flex;
  gap: 4px;
}
#cv {
  touch-action: none;
  flex: 1;
  overflow: auto;
  min-height: 260px;
  user-select: none;
  background: radial-gradient(circle, var(--line) 1px, transparent 1.3px) 0 0/20px 20px;
}
svg text {
  font:
    12px "Trebuchet MS",
    system-ui,
    sans-serif;
  fill: var(--ink);
  user-select: none;
  pointer-events: none;
}
.nd {
  cursor: grab;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}
.nd rect,
.nd polygon {
  stroke-width: 2;
}
.nd text {
  font-size: 13px;
  font-weight: 600;
}
.t-out polygon {
  fill: #dbe7ff;
  stroke: #2a62d6;
}
.t-wait rect {
  fill: #fbe0f0;
  stroke: #c63b8f;
}
.t-dec polygon {
  fill: #fdf0c4;
  stroke: #d99a00;
}
.t-start rect {
  fill: #d3f4df;
  stroke: #1f9d55;
}
.t-end rect {
  fill: #fde0e1;
  stroke: #e5484d;
}
.t-sub rect {
  fill: #d2f2f3;
  stroke: #16a0a8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .t-out polygon {
    fill: #1d2d4a;
    stroke: var(--acc);
  }
  :root:not([data-theme="light"]) .t-wait rect {
    fill: #462e46;
    stroke: #e05aa8;
  }
  :root:not([data-theme="light"]) .t-dec polygon {
    fill: #453c22;
    stroke: #d99a00;
  }
  :root:not([data-theme="light"]) .t-start rect {
    fill: #1b3c34;
    stroke: var(--ok);
  }
  :root:not([data-theme="light"]) .t-end rect {
    fill: #432932;
    stroke: #e5484d;
  }
  :root:not([data-theme="light"]) .t-sub rect {
    fill: #193a44;
    stroke: #16a0a8;
  }
}
:root[data-theme="dark"] .t-out polygon {
  fill: #1d2d4a;
  stroke: var(--acc);
}
:root[data-theme="dark"] .t-wait rect {
  fill: #462e46;
  stroke: #e05aa8;
}
:root[data-theme="dark"] .t-dec polygon {
  fill: #453c22;
  stroke: #d99a00;
}
:root[data-theme="dark"] .t-start rect {
  fill: #1b3c34;
  stroke: var(--ok);
}
:root[data-theme="dark"] .t-end rect {
  fill: #432932;
  stroke: #e5484d;
}
:root[data-theme="dark"] .t-sub rect {
  fill: #193a44;
  stroke: #16a0a8;
}
.t-sub path {
  fill: none;
  stroke: #16a0a8;
  stroke-width: 2;
}
.t-file path {
  fill: #ece4ff;
  stroke: #7c4dff;
}
:root:not([data-theme="light"]) .t-file path {
  fill: #2e2550;
  stroke: #9b7bff;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .t-file path {
    fill: #ece4ff;
    stroke: #7c4dff;
  }
}
:root[data-theme="light"] .t-file path {
  fill: #ece4ff;
  stroke: #7c4dff;
}
body:not(.gcse) .gco {
  display: none !important;
}
.sel > rect,
.sel > polygon,
.sel > path {
  stroke-width: 3.5;
}
/* Selected blocks: a thick glowing ring behind the shape, so the selection is easy to see. */
:root {
  --bg: #eef1f5;
  --panel: #fff;
  --ink: #17202c;
  --mut: #5d6879;
  --line: #d3d9e2;
  --acc: #2a62d6;
  --hl: #f2a900;
  --ok: #1f9d55;
  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  --sel: #2f7dff;
}
:root[data-theme="dark"] {
  --bg: #10151c;
  --panel: #1a212b;
  --ink: #e8edf4;
  --mut: #9aa6b8;
  --line: #2e3846;
  --acc: #3f73e0;
  --hl: #ffc233;
  color-scheme: dark;
  --sel: #5aa2ff;
}
.halo * {
  fill: none !important;
  stroke: var(--sel) !important;
  stroke-width: 12 !important;
  stroke-dasharray: none !important;
  stroke-linejoin: round;
  opacity: 0.55;
  filter: drop-shadow(0 0 6px var(--sel));
}
.halo path:not(:first-child) {
  display: none;
}
.pend rect,
.pend polygon {
  stroke-dasharray: 5 3;
}
/* The block that is running: the same glowing yellow outline as the blocks a failed check points at. */
.nd.cur > :is(rect, polygon, path):first-of-type {
  stroke: var(--hl) !important;
  stroke-width: 4 !important;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--hl) 80%, transparent));
}
.pt {
  border-collapse: collapse;
  font:
    13px ui-monospace,
    Menlo,
    Consolas,
    monospace;
  fill: var(--panel);
  stroke: var(--mut);
  stroke-width: 2;
  cursor: crosshair;
  opacity: 0.45;
}
.nd:hover .pt,
.sel .pt,
.pend .pt {
  opacity: 1;
}
.pt:hover {
  fill: var(--acc);
}

.hit {
  fill: none;
  stroke: transparent;
  stroke-width: 12;
  cursor: pointer;
  pointer-events: stroke;
}
.hit:hover {
  stroke: rgba(229, 72, 77, 0.18);
}
.edh {
  fill: none;
  stroke: var(--panel);
  stroke-width: 9;
  stroke-linejoin: round;
}
.eg:hover .ed {
  stroke: var(--acc);
  stroke-width: 3;
  marker-end: url(#arh);
}
svg .yn text {
  font-size: 10.5px;
  font-weight: 700;
  fill: #fff;
  letter-spacing: 0.2px;
}
svg .yn rect {
  stroke: var(--panel);
  stroke-width: 1.5;
}
svg .yn.yy rect {
  fill: #1f9d55;
}
svg .yn.nn rect {
  fill: #e5484d;
}
aside {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow: auto;
}

#ins {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
}
#ins button.on {
  background: #ff8a1f;
  border-color: #ff8a1f;
  color: #111;
}
#st {
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  color: var(--mut);
  min-height: 20px;
}
details {
  padding: 8px 12px;
}
summary {
  cursor: pointer;
  font-weight: 700;
}
pre {
  margin: 8px 0 0;
  max-height: 240px;
  overflow: auto;
  font:
    12px/1.4 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  background: var(--bg);
  padding: 8px;
  border-radius: 8px;
}
#sv {
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
#sv input {
  flex: 1;
  min-width: 180px;
}
#sv[hidden] {
  display: none;
}
#svx {
  padding: 6px 10px;
  color: var(--mut);
}
#tsk {
  flex-basis: 100%;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}
#tsk summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--acc);
  font-size: 13px;
}
#tsk .tr {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  font-size: 13px;
}
#tsk .grow {
  flex: 1;
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 240px;
}
#tsk .grow input {
  flex: 1;
}
#tsk input[type="checkbox"] {
  flex: none;
  min-width: 0;
}

.tskx {
  position: absolute;
  right: 4px;
  top: 4px;
  border: 0;
  background: none;
  padding: 2px 5px;
  font-size: 12px;
  color: var(--mut);
}
body.gcse #tsk {
  display: none;
}
.tskm {
  position: relative;
  padding-right: 26px !important;
  margin: 0 0 2px;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(242, 169, 0, 0.14);
  border: 1px solid rgba(242, 169, 0, 0.45);
  font-size: 13px;
  line-height: 1.4;
}
.tskm b {
  display: block;
  font-size: 12px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #a06d00;
}
.chc.tk {
  box-shadow: 0 0 0 3px rgba(242, 169, 0, 0.55);
}
.ls {
  opacity: 0.15;
  transition: opacity 0.2s;
}
.ls.on {
  opacity: 1;
}
.vis {
  opacity: 0;
  transition: opacity 0.3s;
}
.rbar {
  transform-origin: 166.5px 150px;
  transform: rotate(80deg);
  transition: transform calc(1.2s * var(--anim, 1));
}
.rbar.on {
  transform: rotate(0deg);
}
.uns {
  opacity: 0;
  transition: opacity 0.2s;
}
.uns.on {
  opacity: 1;
  animation: bfl 0.6s steps(1) infinite;
}
.ldl,
.ldr {
  transition: transform calc(0.8s * var(--anim, 1));
}
.ldl.on {
  transform: translateX(-22px);
}
.ldr.on {
  transform: translateX(22px);
}
[data-car] {
  transition: transform 0.25s linear;
}
.flow {
  opacity: 0;
}
.flow.on {
  opacity: 1;
  animation: fl 0.5s linear infinite;
}
@keyframes fl {
  to {
    stroke-dashoffset: -9;
  }
}
.flash.on {
  animation: bfl 0.5s steps(1) infinite;
}
.vis.on {
  opacity: 1;
}
.vis.neg {
  opacity: 1;
}
.vis.neg.on {
  opacity: 0;
}
.nv {
  opacity: 0;
  transition: opacity 0.5s;
}
.nv.on {
  opacity: 1;
}
.dv {
  transition: opacity 0.5s;
}
.dv.on {
  opacity: 0;
}
.sea {
  fill: #2a7fc4;
  transition: fill 0.5s;
}
.sea.on {
  fill: #123a66;
}
#mimic .wt {
  font-size: 5px;
  font-weight: 700;
  fill: #4a4630;
}
#mimic .wt.on {
  fill: #ff8a1f;
}
.drive {
  animation: dr 2.8s linear infinite;
}
@keyframes dr {
  from {
    transform: translateX(-50px);
  }
  to {
    transform: translateX(270px);
  }
}
.drive2 {
  animation: dr2 3.2s linear infinite;
}
@keyframes dr2 {
  from {
    transform: translateX(60px);
  }
  to {
    transform: translateX(-260px);
  }
}
.walkup {
  animation: wu 3.6s ease-in-out infinite;
}
@keyframes wu {
  0% {
    transform: translateY(0);
  }
  80%,
  100% {
    transform: translateY(-104px);
  }
}
.sail {
  animation: sl 22s linear infinite;
}
@keyframes sl {
  from {
    transform: translateX(-40px);
  }
  to {
    transform: translateX(300px);
  }
}
.gs {
  transform-box: fill-box;
  transform-origin: center;
}
.ls.on .gs {
  animation: spin 1.6s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.wave {
  opacity: 0;
  animation: wv 1.2s ease-out infinite;
}
.w2 {
  animation-delay: 0.2s;
}
.w3 {
  animation-delay: 0.4s;
}
@keyframes wv {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .drive,
  .drive2,
  .walkup,
  .sail,
  .ls.on .gs {
    animation-duration: 12s;
  }
}
.inp {
  fill: #777;
}
.inp.on {
  fill: #ff8a1f;
}
.sky {
  fill: #8fd0ff;
  transition: fill 0.5s;
}
.sky.on {
  fill: #0b1b3a;
}
.sun {
  fill: #ffe27a;
  transition: fill 0.5s;
}
.sun.on {
  fill: #dfe7f5;
}
.rot {
  transform-origin: 130px 61px;
  animation: sw 3s linear infinite;
  animation-play-state: paused;
}
.rot.on {
  animation-play-state: running;
}
@keyframes sw {
  50% {
    transform: scaleX(-1);
  }
  100% {
    transform: scaleX(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .rot.on {
    animation-duration: 9s;
  }
}
@media (max-width: 860px) {
  main {
    /* minmax(0, …) so a long line of Python scrolls inside its box instead of widening the page. */
    grid-template-columns: minmax(0, 1fr);
    overflow: auto;
  }
  #cv {
    min-height: 420px;
  }
  #gut {
    display: none;
  }
  aside {
    margin-top: 12px;
    /* On a narrow screen the page scrolls as a whole, so the side panel shows at its full height. */
    overflow: visible;
    min-height: auto;
  }
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}
.seg button {
  border: 0;
  border-radius: 0;
  padding: 6px 12px;
}
.seg button.on {
  background: var(--acc);
  color: #fff;
}
body.gcse .k3 {
  display: none !important;
}
body:not(.gcse) .g3 {
  display: none !important;
}
.nd.gc text {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 600;
}

.frb {
  fill: rgba(42, 98, 214, 0.035);
  stroke: var(--line);
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
  pointer-events: none;
}
svg .frt {
  font-size: 12px;
  font-weight: 700;
  fill: var(--mut);
  cursor: move;
  pointer-events: auto;
  user-select: none;
}
svg .frt:hover {
  fill: var(--acc);
}
.gtxi {
  min-width: 220px;
  max-width: 100%;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

#code::selection {
  background: rgba(42, 98, 214, 0.3);
}
.hk {
  color: #a626a4;
  font-weight: 600;
}
.hs {
  color: #3f8f3a;
}
.hn {
  color: #986801;
}
.hc {
  color: #8a94a3;
  font-style: italic;
}
.hb {
  color: #0e7fae;
}
.hf {
  color: #2f66d8;
  font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hk {
    color: #c678dd;
  }
  :root:not([data-theme="light"]) .hs {
    color: #98c379;
  }
  :root:not([data-theme="light"]) .hn {
    color: #d19a66;
  }
  :root:not([data-theme="light"]) .hc {
    color: #7f8a99;
  }
  :root:not([data-theme="light"]) .hb {
    color: #56b6c2;
  }
  :root:not([data-theme="light"]) .hf {
    color: #61afef;
  }
}
:root[data-theme="dark"] .hk {
  color: #c678dd;
}
:root[data-theme="dark"] .hs {
  color: #98c379;
}
:root[data-theme="dark"] .hn {
  color: #d19a66;
}
:root[data-theme="dark"] .hc {
  color: #7f8a99;
}
:root[data-theme="dark"] .hb {
  color: #56b6c2;
}
:root[data-theme="dark"] .hf {
  color: #61afef;
}
#hlp {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  padding: 8px;
  font: inherit;
  white-space: pre;
  color: var(--ink);
  pointer-events: none;
  min-width: 100%;
  box-sizing: border-box;
  tab-size: 4;
  max-height: none;
  overflow: visible;
  background: transparent;
  border-radius: 0;
}
#popb textarea {
  font:
    12px/1.45 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--panel);
  color: var(--ink);
  resize: vertical;
}
#insp textarea {
  max-width: 100%;
  flex: 1 1 280px;
  font:
    12px/1.45 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  min-width: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--panel);
  color: var(--ink);
  resize: vertical;
}
.ed {
  fill: none;
  stroke: var(--mut);
  stroke-width: 2;
  display: flex;
  font:
    13px/20px ui-monospace,
    Menlo,
    Consolas,
    monospace;
  max-height: 44vh;
  min-height: 220px;
  overflow: auto;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
#gut2 {
  padding: 8px 8px 8px 6px;
  color: var(--mut);
  text-align: right;
  user-select: none;
  background: var(--bg);
  min-width: 34px;
  white-space: pre;
  flex: none;
}
.edw {
  position: relative;
  flex: 1;
  min-width: 0;
}
#code {
  -webkit-text-fill-color: transparent;
  caret-color: var(--ink);
  display: block;
  width: 100%;
  min-height: 100%;
  border: 0;
  border-radius: 0;
  resize: none;
  padding: 8px;
  margin: 0;
  font: inherit;
  background: transparent;
  color: var(--ink);
  tab-size: 4;
  white-space: pre;
  overflow: hidden;
  position: relative;
  outline: none;
}
#hl {
  position: absolute;
  left: 0;
  right: 0;
  height: 20px;
  background: rgba(242, 169, 0, 0.3);
  pointer-events: none;
}
#hl.err {
  background: rgba(229, 72, 77, 0.28);
}
#con {
  font:
    13px/1.5 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  padding: 8px 10px;
  min-height: 90px;
  max-height: 28vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
#con .ce {
  color: #e5484d;
  font-weight: 700;
}
#con .ci {
  color: var(--acc);
  font-weight: 700;
}
#con .cn {
  color: var(--mut);
  font-style: italic;
}
#cform {
  display: flex;
  gap: 6px;
  padding: 0 10px 10px;
}
#cform[hidden] {
  display: none;
}
#cin {
  flex: 1;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
#trace {
  max-height: 30vh;
  overflow: auto;
}
#trace table {
  border-collapse: collapse;
  width: 100%;
  font:
    12px ui-monospace,
    Menlo,
    Consolas,
    monospace;
}
#trace th,
#trace td {
  border: 1px solid var(--line);
  padding: 3px 7px;
  text-align: left;
  white-space: nowrap;
}
#trace th {
  position: sticky;
  top: 0;
  background: var(--bg);
  font-weight: 700;
}

body.home #home {
  display: flex;
}
body.home header,
body.home main,
body.home #sv {
  display: none !important;
}

.hw {
  width: min(860px, 100%);
}
.hhead {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
  color: var(--mut);
}
.hhead h2 {
  margin: 0;
  font:
    700 34px/1.1 Georgia,
    "Times New Roman",
    serif;
  color: var(--ink);
}
.hhead p {
  margin: 4px 0 0;
  font-size: 16px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}
.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  transition:
    transform 0.15s,
    box-shadow 0.15s,
    border-color 0.15s;
}
.card:hover,
.card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.14);
  border-color: var(--acc);
}
.cimg text {
  font:
    10px ui-monospace,
    Menlo,
    Consolas,
    monospace;
}
.cimg {
  width: 100%;
  height: auto;
  border-radius: 10px;
  margin-bottom: 6px;
}
.card b {
  font:
    700 21px Georgia,
    serif;
}
.card .cd {
  color: var(--mut);
  line-height: 1.5;
}
.tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(31, 157, 85, 0.15);
  color: #1f9d55;
}
.tag.g {
  background: rgba(42, 98, 214, 0.15);
  color: var(--acc);
}
.card .go {
  margin-top: auto;
  padding-top: 6px;
  color: var(--acc);
  font-weight: 700;
}
/* The logo and name in the top bar go back to the start screen. */
#hm {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  margin-right: 6px;
  border-color: transparent;
  background: transparent;
}
#hm:hover,
#hm:focus-visible {
  border-color: var(--line);
  background: var(--panel);
}
#hm .hmname {
  font:
    700 18px/1 Georgia,
    "Times New Roman",
    serif;
  color: var(--ink);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:disabled:hover {
  border-color: var(--line);
}
@media (prefers-reduced-motion: reduce) {
  .card {
    transition: none;
  }
  .card:hover {
    transform: none;
  }
}
#ghost {
  display: none;
  position: fixed;
  z-index: 60;
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0.9;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.18));
}
body.placing #cv {
  cursor: copy;
}
body.placing,
body.placing * {
  cursor: copy !important;
}
#adv {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-left: 8px;
  border-left: 2px solid var(--line);
}
#adv[hidden] {
  display: none;
}
#advt svg {
  transition: transform 0.2s;
}
#advt[aria-expanded="true"] svg {
  transform: rotate(180deg);
}
body.gcse #advt {
  display: none;
}
body.gcse #adv {
  display: flex !important;
  padding-left: 0;
  border-left: 0;
}
#vbox[hidden] {
  display: none !important;
}
#hmain[hidden],
#mpick[hidden] {
  display: none;
}
.mph {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.mph h3 {
  margin: 0;
  font:
    700 26px Georgia,
    serif;
}
.mgrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 900px) {
  .mgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .mgrid {
    grid-template-columns: 1fr;
  }
}
#mpick {
  width: min(1040px, 100%);
}
body.home .hw:has(#mpick:not([hidden])) {
  width: min(1040px, 100%);
}
#mcont[hidden] {
  display: none;
}
.mcard {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  transition:
    transform 0.15s,
    box-shadow 0.15s,
    border-color 0.15s;
}
.mcard:hover,
.mcard:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.13);
  border-color: var(--acc);
}
.mth {
  width: 132px;
  flex: none;
  height: auto;
  aspect-ratio: 260/210;
  border-radius: 8px;
  display: block;
  background: #e3e9f0;
}
.mtx {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.mcard b {
  font:
    700 16px Georgia,
    serif;
}
.mcard .cd {
  font-size: 13px;
  color: var(--mut);
  line-height: 1.45;
}

.mth .ls {
  opacity: 0.2;
}
.mth .wt {
  font-size: 5px;
  font-weight: 700;
  fill: #4a4630;
}
.mth .ro {
  font:
    700 9px ui-monospace,
    Menlo,
    Consolas,
    monospace;
  fill: #7cfc9a;
}
.mth .fs {
  font:
    700 12px "Trebuchet MS",
    system-ui,
    sans-serif;
  letter-spacing: 2px;
  fill: #4a2626;
}
@media (prefers-reduced-motion: reduce) {
  .mcard {
    transition: none;
  }
  .mcard:hover {
    transform: none;
  }
}
#home {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  overflow: auto;
  background: radial-gradient(circle, var(--line) 1px, transparent 1.3px) 0 0/22px 22px;
  position: relative;
}
.hth {
  position: absolute;
  top: 14px;
  right: 16px;
}
.thb {
  font-size: 17px;
  line-height: 1;
  padding: 6px 10px;
  min-width: 38px;
}
#ctl {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}
#ctl .sep {
  width: 1px;
  align-self: stretch;
  background: var(--line);
  margin: 2px 4px;
}
.spl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.spl input {
  padding: 0;
  width: 110px;
}
body.asideEmpty main {
  grid-template-columns: minmax(0, 1fr) 0 0;
}
body.asideEmpty #gut {
  display: none;
}
body.asideEmpty aside {
  overflow: visible;
  min-width: 0;
  margin: 0;
}

/* Practice: category tabs, hints and the dashed blocks to complete */
.pcats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.pcats button {
  font-size: 12px;
  padding: 3px 8px;
}
.pcats button.on {
  background: var(--hl);
  color: var(--bg);
  border-color: var(--hl);
}
.pcats button.on .mut {
  color: inherit;
  opacity: 0.75;
}
.phint {
  font-size: 12.5px;
  margin: 0 0 8px;
}
.phint summary {
  cursor: pointer;
  color: var(--hl);
}
.nd.blank > :is(rect, polygon, path):first-of-type {
  stroke: var(--hl);
  stroke-dasharray: 6 4;
  stroke-width: 2.5;
}

/* The About button in the top bar sits in line with the other buttons. */
header .hinf {
  position: static;
}

/* ---- Challenges panel: stands out as the place to look ---- */
#chbox {
  --chc: var(--acc);
  border: 2px solid color-mix(in srgb, var(--chc) 70%, transparent);
  box-shadow: 0 6px 22px -10px color-mix(in srgb, var(--chc) 70%, transparent);
  overflow: hidden;
}
#chbox.alldone {
  --chc: #30c46b;
}
#chbox .chhd {
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(
    120deg,
    color-mix(in srgb, var(--chc) 26%, var(--panel)),
    color-mix(in srgb, var(--hl) 14%, var(--panel))
  );
  border-bottom: 0;
}
.chico {
  flex: none;
  color: var(--hl);
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}
.chtt {
  display: grid;
  line-height: 1.15;
}
#chbox .chtt b {
  font-size: 16px;
  letter-spacing: 0.2px;
}
#chprog {
  font-size: 12px;
  color: var(--mut);
  font-weight: 600;
}
.chbar {
  height: 5px;
  background: color-mix(in srgb, var(--chc) 15%, var(--panel));
}
.chbar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #30c46b, #7be3a0);
  transition: width 0.5s ease;
}
#chin {
  padding: 10px 10px 2px;
}
#chin[hidden] {
  display: none;
}
#chin > .cht {
  margin-bottom: 2px;
}
#chin #chl {
  padding: 8px 0 10px;
}
.chc {
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  width: 34px;
  height: 34px;
  font-size: 13px;
  transition:
    transform 0.12s,
    background 0.12s;
}
.chc:hover {
  transform: translateY(-1px);
  border-color: var(--chc);
}
.chc.sel {
  outline-offset: 2px;
  background: var(--chc);
  border-color: var(--chc);
  color: #fff;
  outline: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chc) 30%, transparent);
}
.chc.dn.sel {
  background: #30c46b;
  border-color: #30c46b;
  box-shadow: 0 0 0 3px rgba(48, 196, 107, 0.35);
}
.chcard {
  display: grid;
  --cc: var(--acc);
  border: 0;
  border-left: 4px solid var(--cc);
  border-radius: 10px;
  padding: 11px 12px 12px;
  gap: 6px;
  background: color-mix(in srgb, var(--cc) 11%, var(--panel));
}
.chcard.bon {
  border-color: #8a5cf6;
  --cc: #8a5cf6;
}
.chcard.bug {
  border-color: #e5484d;
  --cc: #e5484d;
}
.chcard.dn {
  border-color: #30c46b;
  --cc: #30c46b;
}
.chlab {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--cc);
}
.cth b {
  font-size: 16px;
}
.chcard p {
  margin: 0;
  line-height: 1.45;
  font-size: 13.5px;
}
.chf {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.chf .chd {
  order: 3;
  font-size: 13.5px;
  font-weight: 700;
  padding: 8px 14px;
}
.chd.pri.on {
  background: #30c46b;
  border-color: #30c46b;
}
/* A short glow when a mimic opens, so students notice the challenges. */
#chbox.nudge {
  animation: chglow 1.4s ease-in-out 3;
}
@keyframes chglow {
  50% {
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--hl) 55%, transparent);
    border-color: var(--hl);
  }
}
@media (prefers-reduced-motion: reduce) {
  #chbox.nudge {
    animation: none;
  }
  .chbar i {
    transition: none;
  }
}

/* While the flowchart picture is being made, switch colours instantly (no fades). */
html.snap *,
html.snap *::before,
html.snap *::after {
  transition: none !important;
}

/* Blocks to look at after a failed challenge check */
.nd.look > :is(rect, polygon, path):first-of-type {
  stroke: var(--hl) !important;
  stroke-width: 4 !important;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--hl) 80%, transparent));
  animation: lookpulse 1.2s ease-in-out 3;
}
@keyframes lookpulse {
  50% {
    stroke-width: 6;
  }
}
.chlook {
  display: block;
  margin-top: 5px;
  font-weight: 600;
}
.chsm {
  margin-left: 4px;
  font-size: 12px;
  padding: 2px 8px;
}
@media (prefers-reduced-motion: reduce) {
  .nd.look > :is(rect, polygon, path):first-of-type {
    animation: none;
  }
}

.chcard .chr.stale {
  background: color-mix(in srgb, var(--hl) 14%, transparent);
  color: var(--ink);
}

/* Wide side panel (KS3): the mimic on the left, the challenges beside it on the right. */
body:not(.gcse) aside.wide {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-auto-rows: min-content;
  align-content: start;
  column-gap: 12px;
}
body:not(.gcse) aside.wide > #mbox {
  grid-column: 1;
  grid-row: 1 / span 6;
}
body:not(.gcse) aside.wide > .box:not(#mbox) {
  grid-column: 2;
}
#mimic svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px 12px 0 0;
  background: #e3e9f0;
  margin-inline: auto;
}

/* ---- GCSE chooser on the home screen ---- */
#gpick[hidden] {
  display: none;
}

/* ---- GCSE Paper 2 practice screen ---- */
body.p2mode header,
body.p2mode main,
body.p2mode #sv,
body.p2mode #home {
  display: none !important;
}
#p2 {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#p2[hidden] {
  display: none;
}
.p2top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
#p2hm {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  border-color: transparent;
  background: transparent;
}
#p2hm:hover,
#p2hm:focus-visible {
  border-color: var(--line);
  background: var(--bg);
}
#p2hm .hmname {
  font:
    700 18px/1 Georgia,
    "Times New Roman",
    serif;
  color: var(--ink);
}
.p2title {
  font-weight: 700;
  color: var(--mut);
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.p2top .hinf {
  position: static;
}
.p2auto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--mut);
  cursor: pointer;
}
.p2score {
  font-weight: 700;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ink);
}
.p2body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}
.p2nav {
  border-right: 1px solid var(--line);
  padding: 14px 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--panel);
}
.p2topic {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.p2topic span {
  font-size: 12px;
  color: var(--mut);
}
.p2topic.on {
  border-color: var(--acc);
  background: color-mix(in srgb, var(--acc) 14%, var(--panel));
  box-shadow: inset 3px 0 0 var(--acc);
}
.p2qs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.p2qn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  font-weight: 700;
  font-size: 13px;
}
.p2qn.on {
  background: var(--acc);
  border-color: var(--acc);
  color: #fff;
}
.p2qn.full {
  box-shadow: 0 0 0 2px #30c46b;
}
.p2qn.part {
  box-shadow: 0 0 0 2px var(--hl);
}
.p2qn.zero {
  box-shadow: 0 0 0 2px #e5484d;
}
.p2main {
  overflow: auto;
  padding: 22px 26px 40px;
  background: radial-gradient(circle, var(--line) 1px, transparent 1.3px) 0 0/22px 22px;
}
.p2card {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 24px 22px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 6px 24px -12px rgba(0, 0, 0, 0.35);
}
.p2head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--mut);
}
.p2marks {
  font:
    700 14px Georgia,
    serif;
  color: var(--ink);
}
.p2card h2 {
  margin: 4px 0 10px;
  font:
    700 22px/1.2 Georgia,
    "Times New Roman",
    serif;
}
.p2badge {
  font:
    700 11px system-ui,
    sans-serif;
  letter-spacing: 0.04em;
  vertical-align: middle;
  padding: 2px 8px;
  border-radius: 99px;
  background: color-mix(in srgb, #8a5cf6 18%, transparent);
  color: #8a5cf6;
}
.p2qtext {
  font-size: 15px;
  line-height: 1.55;
  margin: 0 0 14px;
}
.p2qtext code,
.p2t code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--bg);
}
.p2lang {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--mut);
  margin-bottom: 4px;
}
.p2code,
.p2data {
  margin: 0 0 14px;
}
.p2code pre {
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  font:
    13.5px/1.55 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  overflow: auto;
}
.p2t {
  border-collapse: collapse;
  font-size: 13.5px;
}
.p2t th,
.p2t td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
}
.p2t th {
  background: var(--bg);
  font-weight: 700;
}
.p2gridw {
  overflow: auto;
  margin-bottom: 4px;
}
.p2grid input,
.p2grid select {
  width: 100%;
  box-sizing: border-box;
  min-width: 70px;
  padding: 5px 8px;
}
.p2grid td:has(input),
.p2grid td:has(select) {
  padding: 3px;
}
.p2grid input,
.p2short input {
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.bad {
  border-color: #e5484d !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, #e5484d 30%, transparent);
}
.good {
  border-color: #30c46b !important;
}
.p2mc {
  display: grid;
  gap: 8px;
}
.p2opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  cursor: pointer;
}
.p2opt:hover {
  border-color: var(--acc);
}
.p2opt:has(input:checked) {
  border-color: var(--acc);
  background: color-mix(in srgb, var(--acc) 12%, var(--panel));
}
.p2short {
  display: grid;
  gap: 10px;
}
.p2short label {
  display: grid;
  grid-template-columns: minmax(120px, max-content) minmax(0, 320px);
  align-items: center;
  gap: 12px;
  font-weight: 600;
}
.p2ed textarea,
.p2txt,
.p2try textarea {
  width: 100%;
  box-sizing: border-box;
  font:
    13.5px/1.55 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  resize: vertical;
  tab-size: 4;
}
.p2src {
  min-height: 180px;
}
.p2src.p2sql {
  min-height: 80px;
}
.p2txt {
  font: 15px/1.55 inherit;
  font-family: inherit;
}
.p2try {
  margin-top: 8px;
  font-size: 13px;
}
.p2try summary {
  cursor: pointer;
  color: var(--acc);
  font-weight: 600;
}
.p2try label {
  display: block;
  margin: 8px 0 6px;
  color: var(--mut);
}
.p2out {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: #0d1117;
  color: #e8edf4;
  font:
    13px/1.5 ui-monospace,
    Menlo,
    Consolas,
    monospace;
  white-space: pre-wrap;
  min-height: 1.5em;
}
.p2out:empty {
  display: none;
}
.p2res {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  border-left: 4px solid var(--mut);
  background: var(--bg);
  line-height: 1.5;
}
.p2res.ok {
  border-left-color: #30c46b;
  background: color-mix(in srgb, #30c46b 12%, var(--panel));
}
.p2res.part {
  border-left-color: var(--hl);
  background: color-mix(in srgb, var(--hl) 12%, var(--panel));
}
.p2res.no {
  border-left-color: #e5484d;
  background: color-mix(in srgb, #e5484d 10%, var(--panel));
}
.p2res.info {
  border-left-color: var(--acc);
  background: color-mix(in srgb, var(--acc) 10%, var(--panel));
}
.p2res .p2t {
  margin-top: 8px;
}
.p2why {
  margin: 6px 0 0;
}
.p2scheme {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px dashed #8a5cf6;
  background: color-mix(in srgb, #8a5cf6 8%, var(--panel));
}
.p2scheme ul {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: grid;
  gap: 6px;
}
.p2scheme label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
}
.p2scheme input {
  margin-top: 3px;
}
.p2self {
  margin: 0;
}
.p2btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  align-items: center;
}
@media (max-width: 760px) {
  .p2body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .p2nav {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    flex-wrap: wrap;
    padding: 10px 12px;
    max-height: 40vh;
  }
  .p2topic {
    flex: 1 1 140px;
  }
  .p2qs {
    width: 100%;
    margin-top: 4px;
    padding-top: 8px;
  }
  .p2main {
    padding: 14px 12px 30px;
  }
  .p2card {
    padding: 16px;
  }
  .p2title {
    display: none;
  }
  .p2short label {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* The small arrowheads along an arrow that show which way it goes. */
.dir {
  fill: none;
  stroke: var(--mut);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.eg:hover .dir {
  stroke: var(--acc);
}

/* The accessibility button, which opens the display options. */
.fsb {
  font:
    700 13px/1 Georgia,
    "Times New Roman",
    serif;
  padding: 6px 9px;
  min-width: 38px;
}
.fsb svg {
  display: block;
  margin: -2px auto;
}
.fsb.on {
  background: var(--acc);
  border-color: var(--acc);
  color: #fff;
}
.hfs {
  position: absolute;
  top: 14px;
  right: 112px;
}

/* ---- Bigger text (display options): the shapes menu and the challenges grow to 38px, and the flowchart
   is zoomed so its text is 38px too. The top bar and the rest of the app keep their normal size. ---- */
html.bigtext .tools button,
html.bigtext .tools b {
  font-size: 38px;
}
/* Long shape names wrap onto two lines so the menu does not squeeze the flowchart. */
html.bigtext .tools {
  max-width: 260px;
}
html.bigtext .tools button {
  white-space: normal;
  line-height: 1.05;
  text-align: left;
}
html.bigtext .tools svg {
  width: 44px;
  height: 28px;
}
html.bigtext #chbox,
html.bigtext #chbox *:not(svg):not(svg *) {
  font-size: 38px !important;
}
/* At this size a button can be wider than a phone screen, so let its words wrap rather than
   stretching the challenge card past the edge of the panel. */
html.bigtext .chf button {
  white-space: normal;
}
html.bigtext .chcard {
  min-width: 0;
}
html.bigtext #chbox .chc {
  width: auto;
  min-width: 58px;
  height: 58px;
}

/* The Hide picture button on the mimic only shows in bigger text mode. */
#mmin {
  display: none;
  margin-right: 6px;
}
html.bigtext #mmin {
  display: inline-block;
}
html.bigtext #mbox.mini #mimic,
html.bigtext #mbox.mini .mt {
  display: none;
}

/* ---- Display options menu (opened by the accessibility buttons) ---- */
#dispm {
  position: fixed;
  z-index: 80;
  width: 300px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 4px;
}
#dispm[hidden] {
  display: none;
}
#dispm > b {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mut);
  padding: 2px 6px 4px;
}
.dopt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.dopt:hover {
  background: var(--bg);
}
.dopt input {
  flex: none;
  margin: 1px 0 0;
  padding: 0;
  width: 18px;
  height: 18px;
  accent-color: var(--acc);
}
.dopt span {
  display: grid;
}
.dopt small {
  color: var(--mut);
  font-size: 12.5px;
}

/* ---- Dyslexia-friendly: a clear rounded font, more space between letters, words and lines,
   no serif headings, and softer, lower-glare colours. Code keeps its monospace font. ---- */
:root.dys:not([data-theme="dark"]) {
  --bg: #f6efdd;
  --panel: #fdf8ec;
  --ink: #1f2328;
  --mut: #4f5560;
  --line: #d9cfb8;
}
:root.dys[data-theme="dark"] {
  --bg: #1d1f23;
  --panel: #26292e;
  --ink: #e9e3d6;
  --mut: #b9b2a5;
  --line: #3b3f46;
}
/* OpenDyslexic (free, SIL Open Font Licence) comes from cdnjs. The browser only downloads it once
   Dyslexia-friendly is switched on; until it arrives, or if it cannot, Verdana is used instead. */
@font-face {
  font-family: "OpenDyslexic";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("https://cdnjs.cloudflare.com/ajax/libs/fontsource-opendyslexic/5.3.0/files/opendyslexic-latin-400-normal.woff2")
    format("woff2");
}
@font-face {
  font-family: "OpenDyslexic";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("https://cdnjs.cloudflare.com/ajax/libs/fontsource-opendyslexic/5.3.0/files/opendyslexic-latin-700-normal.woff2")
    format("woff2");
}
html.dys body {
  font-family: OpenDyslexic, Verdana, Tahoma, "Segoe UI", sans-serif;
  letter-spacing: 0.02em;
  word-spacing: 0.1em;
}
html.dys :is(p, li, .cd, .chcard p, .p2qtext, .p2res, #st, .infob, .dopt small) {
  line-height: 1.7;
}
html.dys
  :is(
    .hhead h2,
    .card b,
    #hm .hmname,
    #p2hm .hmname,
    .p2card h2,
    .p2marks,
    .mph h3,
    .hinf,
    .fsb,
    .infob h4
  ) {
  font-family: OpenDyslexic, Verdana, Tahoma, sans-serif;
  font-style: normal;
}
html.dys :is(#code, #hlp, #gut2, #erlv, .p2src, .p2out, pre, code, textarea, svg text) {
  letter-spacing: 0;
  word-spacing: 0;
}

/* ---- High contrast: darker text, clearer outlines and colour-blind-safe status colours
   (blue for Yes / passed, orange for No / not yet), which also differ in brightness.
   It avoids pure black and white, which can glare, while keeping all text well above AAA contrast. ---- */
:root.hc:not([data-theme="dark"]) {
  --bg: #eceff3;
  --panel: #ffffff;
  --ink: #0b0f14;
  --mut: #2e3440;
  --line: #5a6472;
  --acc: #0047b3;
  --hl: #b35900;
  --ok: #0057a8;
}
:root.hc[data-theme="dark"] {
  --bg: #0b0e13;
  --panel: #161b22;
  --ink: #f5f7fa;
  --mut: #c9d1dc;
  --line: #7d8796;
  --acc: #6aaeff;
  --hl: #ffb000;
  --ok: #6aaeff;
}
html.hc button,
html.hc select,
html.hc input,
html.hc textarea,
html.hc .box {
  border-width: 1.5px;
}
html.hc .nd > :is(rect, polygon, path):first-of-type {
  stroke-width: 2.5;
}
html.hc .ed,
html.hc .dir {
  stroke-width: 2.25;
}
html.hc svg .yn.yy rect {
  fill: #0072b2;
}
html.hc svg .yn.nn rect {
  fill: #d55e00;
}
html.hc .chc.dn,
html.hc .chc.dn.sel {
  background: #0072b2;
  border-color: #0072b2;
}
html.hc .chbar i {
  background: #0072b2;
}
html.hc .p2qn.full {
  box-shadow: 0 0 0 3px #0072b2;
}
html.hc .p2qn.part {
  box-shadow: 0 0 0 3px #e69f00;
  outline: 2px dashed #e69f00;
  outline-offset: 3px;
}
html.hc .p2qn.zero {
  box-shadow: 0 0 0 3px #d55e00;
  outline: 2px dotted #d55e00;
  outline-offset: 3px;
}
html.hc .p2res.ok,
html.hc .chcard .chr.ok {
  border-left-color: #0072b2;
  background: color-mix(in srgb, #0072b2 14%, var(--panel));
}
html.hc .p2res.no,
html.hc .chcard .chr.no {
  border-left-color: #d55e00;
  background: color-mix(in srgb, #d55e00 14%, var(--panel));
}
html.hc .bad {
  border-color: #d55e00 !important;
  border-style: dashed !important;
}
html.hc .good {
  border-color: #0072b2 !important;
}
html.hc .chcard.dn {
  --cc: #0072b2;
  border-color: #0072b2;
}
html.hc .chd.pri.on {
  background: #0072b2;
  border-color: #0072b2;
}
html.hc #cv,
html.hc .p2main,
html.hc #home {
  background-image: radial-gradient(
    circle,
    color-mix(in srgb, var(--line) 25%, transparent) 1px,
    transparent 1.3px
  );
}
/* High contrast: the chosen Main / Bonus / Bugs tab is filled with the accent colour so it stands out. */
html.hc .cht button.on {
  background: var(--acc);
  color: #fff !important;
}
:root.hc[data-theme="dark"] .cht button.on {
  color: #000 !important;
}
/* In dark high contrast the blue is light, so text on blue buttons is black. */
:root.hc[data-theme="dark"] :is(button.pri, button.on, .p2qn.on, .chc.sel, .fsb.on) {
  color: #000;
}

/* The edit popup's title bar is a handle for dragging it around. */
#bpop .ph {
  cursor: move;
  touch-action: none;
  user-select: none;
}
#bpop .ph .grip {
  color: var(--mut);
  font-size: 15px;
  line-height: 1;
  letter-spacing: -1px;
}
#bpop.moving {
  opacity: 0.92;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

/* The › / ‹ tab on the divider hides the side panel (mimic, challenges or code) to the right, and brings it back. */
main {
  position: relative;
}
#asidet {
  position: absolute;
  z-index: 30;
  top: 50%;
  right: calc(var(--aw, 320px) + 12px - 6px);
  width: 22px;
  height: 56px;
  margin-top: -28px;
  padding: 0;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  color: var(--mut);
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
#asidet:hover,
#asidet:focus-visible {
  color: var(--ink);
}
body.home #asidet {
  display: none;
}
body.asideoff main {
  grid-template-columns: minmax(0, 1fr) 10px 0 !important;
}
body.asideoff aside,
body.asideoff #gut::after {
  display: none;
}
body.asideoff #gut {
  cursor: default;
  pointer-events: none;
}
body.asideoff #asidet {
  right: 4px;
}
@media (max-width: 860px) {
  #asidet {
    display: none;
  }
}

/* Smaller laptops and tablets: tighter header and toolbar so they stay on one row. */
@media (max-width: 1180px) {
  header {
    gap: 6px;
    padding: 10px;
  }
  header button,
  header select {
    padding: 6px 8px;
  }
  #mm {
    max-width: 170px;
  }
  .tlab {
    display: none;
  }
  #spd {
    width: 80px;
  }
}
