/* OpenBot style: the PlayGround's blue header, Gilroy and OpenBot blue */
@font-face { font-family: "Gilroy"; font-weight: 400; src: url("fonts/Gilroy-Regular.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Gilroy"; font-weight: 500; src: url("fonts/Gilroy-Medium.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Gilroy"; font-weight: 600; src: url("fonts/Gilroy-SemiBold.woff") format("woff"); font-display: swap; }

:root {
  --blue: #0071c5;
  --blue-dark: #005a9e;
  --blue-wash: #e6f1fa;
  --paper: #f8f9fb;
  --panel: #ffffff;
  --ink: #303030;
  --muted: #687c9e;
  --line: #e1e6ee;
  --red: #ca3143;
  --console: #202020;
  --console-ink: #e4e6ea;
  --radius: 8px;
  --font: "Gilroy", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --blue: #2b8ad8;
    --blue-dark: #4aa0e6;
    --blue-wash: #1d3347;
    --paper: #202020;
    --panel: #303030;
    --ink: #ffffff;
    --muted: #a7b0bf;
    --line: #414141;
    --red: #ff7a85;
    --console: #161616;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 16px/1.5 var(--font); }
h1, h2, h3, p { margin: 0; }
code { font: 400 0.86em var(--mono); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* Header bar, as in the OpenBot PlayGround */
.top { background: #0071c5; color: #fff; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1200px; margin: 0 auto; padding: 14px 24px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand img { width: 40px; height: 40px; }
.brand span { display: block; font-size: 19px; line-height: 1.15; font-weight: 500; }
.top-link { color: #fff; text-decoration: none; border: 1px solid #fff; border-radius: var(--radius); padding: 7px 14px; font-size: 15px; font-weight: 500; white-space: nowrap; }
.top-link:hover { background: rgba(255, 255, 255, 0.12); }
.top-link:focus-visible, .brand:focus-visible { outline-color: #fff; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 40px; max-width: 1200px; margin: 0 auto; padding: 36px 24px 48px; align-items: start; }
.intro { max-width: 60ch; margin-bottom: 28px; }
.intro h1 { font-size: 30px; line-height: 1.2; font-weight: 600; margin-bottom: 8px; }
.intro p { color: var(--muted); }

/* Steps */
.step-list { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.step { counter-increment: step; position: relative; padding: 0 0 30px 46px; }
.step::before {
  content: counter(step);
  position: absolute; left: 0; top: -3px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--blue); color: #fff; font-weight: 600; font-size: 15px;
}
.step::after { content: ""; position: absolute; left: 14.5px; top: 34px; bottom: 6px; width: 1px; border-left: 1px dashed var(--line); }
.step:last-child::after { display: none; }
.step h2 { font-size: 19px; font-weight: 600; margin-bottom: 12px; line-height: 1.3; }
.step .hint { color: var(--muted); font-size: 14px; margin: -6px 0 12px; max-width: 60ch; }

/* Bodies: compact tiles showing the whole robot */
.bodies { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.body-tile { display: flex; flex-direction: column; text-align: left; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; overflow: hidden; }
.body-tile img { width: 100%; height: 72px; object-fit: contain; padding: 6px; background: #fff; display: block; }
.body-tile span { display: block; padding: 7px 9px 0; font-size: 13.5px; font-weight: 500; line-height: 1.25; }
.body-tile small { display: block; padding: 2px 9px 8px; color: var(--muted); font-size: 12px; }
.body-tile:hover { border-color: var(--blue); }
.body-tile[aria-checked="true"] { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); background: var(--blue-wash); }

/* Choices */
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 3px; gap: 3px; }
.segmented button { border: 0; background: none; border-radius: 6px; padding: 7px 14px; cursor: pointer; font-size: 15px; font-weight: 500; }
.segmented button[aria-checked="true"] { background: var(--blue); color: #fff; }
.board-fixed { color: var(--muted); }
.board-fixed strong { color: var(--ink); font-weight: 500; }

.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.mode { text-align: left; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 11px 14px; cursor: pointer; }
.mode strong { display: block; font-weight: 600; }
.mode span { display: block; color: var(--muted); font-size: 13.5px; line-height: 1.35; margin-top: 2px; }
.mode:hover:not(:disabled) { border-color: var(--blue); }
.mode[aria-checked="true"] { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); background: var(--blue-wash); }
.mode:disabled { opacity: 0.45; cursor: not-allowed; }

.batteries { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; font-weight: 500; }
.chip small { color: var(--muted); margin-left: 4px; font-weight: 400; }
.chip:hover { border-color: var(--blue); }
.chip[aria-checked="true"] { border-color: var(--blue); background: var(--blue); color: #fff; }
.chip[aria-checked="true"] small { color: rgba(255, 255, 255, 0.8); }
.custom-battery { display: flex; gap: 16px; margin-top: 12px; }
.custom-battery[hidden] { display: none; }
.mode-extra { margin-top: 14px; }
.mode-extra[hidden] { display: none; }
.mode-extra label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.mode-extra input[type="text"] { width: 200px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }
.mode-extra .hint { margin: 6px 0 0; }
.custom-battery label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.custom-battery input { width: 84px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); }

/* Parts */
.part-group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.part-group h3 { font-size: 13px; font-weight: 600; color: var(--muted); padding: 10px 14px 2px; }
.part { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 9px 14px; border-top: 1px solid var(--line); }
.part-group h3 + .part { border-top: 0; }
.part-text strong { font-weight: 500; }
.part-text small { display: block; color: var(--muted); font-size: 13px; line-height: 1.35; }
.part.changed .part-text strong::after { content: "changed"; margin-left: 8px; padding: 1px 8px; border-radius: 999px; background: var(--blue-wash); color: var(--blue); font-size: 11.5px; font-weight: 600; vertical-align: 1px; }
.part .warn { color: var(--red); }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background 0.15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.switch input:disabled + span { opacity: 0.4; }

/* Robot panel */
.robot { position: sticky; top: 20px; }
.robot-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.robot-image { width: 100%; height: 170px; object-fit: contain; padding: 12px; display: block; background: #fff; border-bottom: 1px solid var(--line); }
.robot-name { padding: 14px 18px 2px; }
.robot-name h2 { font-size: 21px; font-weight: 600; line-height: 1.2; }
.robot-name p { color: var(--muted); font-size: 14px; }

.monitor { margin: 12px 18px 0; background: var(--console); color: var(--console-ink); border-radius: var(--radius); overflow: hidden; }
.monitor-bar { display: flex; justify-content: space-between; padding: 7px 12px; font-size: 12px; color: #9aa1ad; border-bottom: 1px solid #383838; }
.monitor-lines { font: 400 12.5px/1.6 var(--mono); padding: 9px 12px 11px; min-height: 60px; max-height: 220px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.monitor-lines .warn { color: #ffc34d; }
.monitor-lines .error { color: #ff8a8a; }
.monitor-lines .ok { color: #7fd99a; }
.monitor-lines .dim { color: #9aa1ad; }
.progress { height: 4px; background: #383838; }
.progress div { height: 100%; width: 0; background: var(--blue); transition: width 0.2s; }

.actions { padding: 16px 18px 18px; display: grid; gap: 8px; }
.actions button { border-radius: var(--radius); padding: 11px 16px; font-weight: 600; cursor: pointer; }
.primary { background: var(--blue); color: #fff; border: 1px solid var(--blue); font-size: 16px; }
.primary:hover:not(:disabled) { background: var(--blue-dark); border-color: var(--blue-dark); }
.secondary { background: var(--panel); color: var(--blue); border: 1px solid var(--blue); }
.secondary:hover:not(:disabled) { background: var(--blue-wash); }
.actions button:disabled { opacity: 0.45; cursor: not-allowed; }
.actions button.blocked { opacity: 0.45; cursor: not-allowed; }
.secondary.blocked:hover { background: var(--panel); }
.note.warn { color: var(--red); }
.link { background: none; border: 0; color: var(--blue); text-decoration: underline; text-underline-offset: 3px; padding: 4px 0 !important; justify-self: start; font-weight: 500 !important; font-size: 14px; }
.note { color: var(--muted); font-size: 13px; line-height: 1.45; margin: -2px 0 8px; }
.note:empty { display: none; }

.help-button { background: none !important; border: 0 !important; color: var(--blue); text-decoration: underline; text-underline-offset: 3px; padding: 2px 0 !important; justify-self: start; font-weight: 500 !important; font-size: 14px; }
.ways { display: flex; margin-bottom: 6px; }
.ways button { flex: 1; white-space: nowrap; font-size: 14px; padding: 7px 8px; }
.ways button[aria-selected="true"] { background: var(--blue); color: #fff; }
.way { display: grid; gap: 8px; }
.way[hidden] { display: none; }
.ide-steps { margin: 2px 0 4px; padding-left: 20px; font-size: 14px; color: var(--muted); line-height: 1.5; }
.ide-steps li { margin-bottom: 4px; }
.ide-steps a { color: var(--blue); }

/* USB help pop-up */
.help { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: 12px; background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.help::backdrop { background: rgba(20, 24, 32, 0.55); }
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; background: #0071c5; color: #fff; position: sticky; top: 0; }
.help-head h2 { font-size: 19px; font-weight: 600; }
.help-close { background: none; border: 0; color: #fff; font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; }
.help-close:focus-visible { outline-color: #fff; }
.help-body { padding: 18px 22px 22px; font-size: 15px; line-height: 1.55; }
.help-body h3 { font-size: 16px; font-weight: 600; margin: 20px 0 6px; }
.help-body p { margin: 6px 0 0; color: var(--muted); }
.help-body p strong { color: var(--ink); font-weight: 600; }
.help-body a { color: var(--blue); }
.help-steps { margin: 0; padding-left: 22px; }
.help-steps li { margin-bottom: 8px; color: var(--muted); }
.help-steps strong { color: var(--ink); font-weight: 600; }
.drivers { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.drivers th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); }
.drivers td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.drivers td:first-child { font-weight: 600; white-space: nowrap; }

.bottom p + p { margin-top: 4px; }
.bottom { max-width: 1200px; margin: 0 auto; padding: 0 24px 40px; color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 24px 16px 40px; }
  .top-inner { padding: 12px 16px; }
  .bottom { padding: 0 16px 32px; }
  .robot { position: static; }
  .intro h1 { font-size: 25px; }
  .step { padding-left: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
