:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #dfe4ea;
  --text: #1c2430;
  --muted: #667085;
  --accent: #0b7fd4;
  --accent-dark: #0968ae;
  --robot: #ffd400;
  --dark: #15181e;
  --ok: #16803c;
  --ko: #c62828;
  --code-bg: #111827;
  --mono: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  font: 14px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent-dark); }
code { font-family: var(--mono); font-size: 0.92em; }

/* ---------------------------------------------------------------- buttons and fields */
button, select, input:not([type=range]) {
  font: inherit;
  color: inherit;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}
button { cursor: pointer; white-space: nowrap; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
button.danger { color: var(--ko); }
button.small { padding: 2px 8px; font-size: 12px; }

/* A button and its </> twin, which shows the SDK code behind it */
.with-code { display: inline-flex; }
.with-code > button:first-child { border-radius: 6px 0 0 6px; }
button.code {
  padding: 6px 7px;
  margin-left: -1px;
  border-radius: 0 6px 6px 0;
  font: 600 11px var(--mono);
  color: var(--muted);
  background: #f1f3f6;
}
button.code:hover { color: var(--accent-dark); }

/* ---------------------------------------------------------------- header */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  min-height: 64px;
  padding: 8px 16px;
  background: var(--dark);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.robot { width: 44px; height: 44px; color: var(--robot); }
.robot .joints { fill: var(--dark); }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: 0.02em; }
.brand p { margin: 0; color: #aab2c0; font-size: 13px; }
.brand p b { color: #fff; }

.connection, .links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.top input, .top button:not(.primary) { background: #232831; border-color: #39404c; color: #fff; }
.top button.code { color: #aab2c0; }
.top input::placeholder { color: #8791a1; }
.connection input { width: 175px; font-family: var(--mono); }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; background: #232831; color: #aab2c0; }
.badge.demo { background: #4a3d05; color: var(--robot); }
.badge.live { background: #0f3d24; color: #6fdc9b; }

.links { gap: 14px; }
.cta { padding: 7px 14px; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; white-space: nowrap; }
.cta:hover { background: var(--accent-dark); }
.links .icon { display: flex; color: #fff; opacity: 0.85; }
.links .icon:hover, .ua:hover { opacity: 1; }
.ua { display: flex; align-items: center; gap: 10px; color: inherit; font-weight: 600; text-decoration: none; opacity: 0.9; }
.ua img { height: 30px; width: auto; }

/* ---------------------------------------------------------------- layout */
main { display: flex; height: calc(100dvh - 64px); min-height: 600px; }
.editor { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.toolbar label { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; }
#blockly { flex: 1; min-height: 320px; }
/* The block that the robot is executing */
.running > .blocklyPath { stroke: #ffd54a; stroke-width: 4px; filter: drop-shadow(0 0 8px #ffb300); }

aside {
  width: 420px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
}
aside > section { padding: 12px 16px; border-bottom: 1px solid var(--line); }
aside > section.grow { flex: 1; display: flex; flex-direction: column; min-height: 340px; border-bottom: 0; }
h2 { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ---------------------------------------------------------------- robot */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { position: relative; padding: 1px 0 1px 22px; font-size: 13px; }
.checklist li::before { position: absolute; left: 0; font-weight: 700; }
.checklist li.ok::before { content: "✓"; color: var(--ok); }
.checklist li.ko::before { content: "✕"; color: var(--ko); }
.checklist li.info::before { content: "•"; color: var(--muted); }
.checklist li.ko > span { font-weight: 600; color: var(--ko); }
.checklist small { display: block; color: var(--muted); }
.checklist small.detail { font-family: var(--mono); font-size: 11px; overflow-wrap: anywhere; }

.position { margin-top: 8px; font-family: var(--mono); font-size: 12px; }
.position:empty { display: none; }
.position div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 4px; }
.position span { padding: 3px 4px; border-radius: 4px; background: var(--bg); text-align: right; }
.position i { float: left; font-style: normal; color: var(--muted); }
.position small { color: var(--muted); font-family: inherit; }

/* ---------------------------------------------------------------- run */
.override { display: block; color: var(--muted); }
.override output { float: right; color: var(--text); font-weight: 600; }
.override input { width: 100%; accent-color: var(--accent); }
.buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.message { margin: 10px 0 0; padding: 8px 10px; border-radius: 6px; background: var(--bg); }
.message.ok { background: #e7f5ec; color: var(--ok); }
.message.ko { background: #fdecea; }
.message.ko b { display: block; color: var(--ko); overflow-wrap: anywhere; }
.message span { display: block; margin-top: 4px; }

/* ---------------------------------------------------------------- steps and code */
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button[data-tab], .tabs button[data-lang] { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); font-weight: 600; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .small { margin-left: auto; align-self: center; }

.steps { flex: 1; margin: 0; padding: 0; list-style: none; overflow-y: auto; counter-reset: step; font-size: 12px; }
.steps li { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 4px; counter-increment: step; }
.steps li::before { content: counter(step); width: 22px; color: var(--muted); text-align: right; }
.steps li.empty::before { content: none; }
.steps li.empty { color: var(--muted); }
.steps code { flex: 1; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.steps em { font-style: normal; font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.steps li.current { background: #fff8d6; }
.steps li.Executing em { background: var(--robot); color: #000; }
.steps li.Completed em { background: #e7f5ec; color: var(--ok); }
.steps li.Error em { background: #fdecea; color: var(--ko); }
.steps li.ControllerQueued em { background: #e8eefc; color: #2c4fb8; }

.code-view {
  flex: 1;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 8px;
  background: var(--code-bg);
  color: #e5e7eb;
  font: 12px/1.5 var(--mono);
  tab-size: 4;
}
.code-view .c { color: #7c8799; }
.code-view .s { color: #a5d6a7; }
.code-view .k { color: #7cc4ff; }
.code-view .n { color: #ffd98a; }

/* ---------------------------------------------------------------- dialogs */
dialog { width: min(680px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 12px; color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
dialog::backdrop { background: rgba(17, 24, 39, 0.55); }
dialog form { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px; }
dialog header { display: flex; align-items: center; justify-content: space-between; }
dialog h3 { margin: 0; font-size: 17px; }
dialog p, dialog ol { margin: 0; }
dialog ol, dialog ul { padding-left: 20px; }
dialog .code-view { max-height: 50vh; }
dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
dialog label { display: grid; gap: 4px; color: var(--muted); }
.downloads { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.download { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--text); }
.download:hover { border-color: var(--accent); }
.download b { color: var(--accent-dark); font-size: 15px; }
.download span { color: var(--muted); font-size: 12px; }
.safety { margin: 0; color: var(--muted); }

@media (max-width: 900px) {
  main { flex-direction: column; height: auto; }
  aside { width: auto; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  #blockly { min-height: 60vh; }
  .downloads { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------- below the application */
.about { background: var(--dark); color: #d5dae3; padding: 56px 24px 24px; }
.about > * { max-width: 1080px; margin: 0 auto 40px; }
.about h2 { margin: 0 0 12px; font-size: 24px; letter-spacing: 0; text-transform: none; color: #fff; }
.about h3 { margin: 0 0 6px; font-size: 16px; color: var(--robot); }
.about p { margin: 0 0 12px; }
.about a:not(.cta) { color: #7cc4ff; }
.hero p { max-width: 820px; font-size: 16px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; margin-top: 20px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.cards article { padding: 18px; border: 1px solid #2c323c; border-radius: 10px; background: #1b1f27; }
.cards p { margin: 0; }
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.columns ol { margin: 0; padding-left: 20px; }
.columns li { margin-bottom: 8px; }
.about details { border-bottom: 1px solid #2c323c; padding: 10px 0; }
.about summary { cursor: pointer; font-weight: 600; color: #fff; }
.about details p { margin: 8px 0 0; }
.about footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; margin-bottom: 0; padding-top: 20px; border-top: 1px solid #2c323c; font-size: 13px; color: #8791a1; }
.about footer .ua { color: #fff; }
.legal { flex-basis: 100%; font-size: 12px; }
.noscript { padding: 24px; text-align: center; }

@media (max-width: 900px) {
  .cards, .columns { grid-template-columns: 1fr; }
}

@media (min-width: 1200px) { .top { flex-wrap: nowrap; } }
@media (max-width: 1350px) { .top .ua span { display: none; } }

/* The header link to the content below the application */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.more { color: #fff; font-weight: 600; text-decoration: none; opacity: 0.9; white-space: nowrap; }
.more:hover { opacity: 1; text-decoration: underline; }
