:root {
  color-scheme: light;
  --board-ink: #173b40;
  --board-deep: #102f34;
  --sensor-cyan: #287c86;
  --season-gold: #bd7f21;
  --season-light: #f2bd62;
  --safety-red: #c6473f;
  --action-green: #417a61;
  --code-blue: #294f63;
  --paper: #f4f7f2;
  --panel: #ffffff;
  --panel-soft: #edf3ee;
  --ink: #183338;
  --muted: #64797b;
  --line: #c7d5cf;
  --line-strong: #9cb7ad;
  --shadow: 0 18px 50px rgba(20, 55, 58, 0.12);
  --display: "STKaiti", "KaiTi", "KaiTi_GB2312", serif;
  --body: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --utility: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(34, 96, 93, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 96, 93, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 87% 2%, rgba(242, 189, 98, 0.17), transparent 28rem),
    var(--paper);
  background-size: 32px 32px, 32px 32px, auto, auto;
  font-family: var(--body);
}

button,
a,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(40, 124, 134, 0.35);
  outline-offset: 3px;
}

.circuit-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.circuit-line {
  position: absolute;
  width: 34rem;
  height: 34rem;
  border: 1px solid rgba(40, 124, 134, 0.11);
  border-radius: 50%;
}

.line-one {
  right: -18rem;
  top: 8rem;
}

.line-two {
  left: -21rem;
  bottom: -8rem;
}

.circuit-node {
  position: absolute;
  width: 9px;
  height: 9px;
  border: 2px solid var(--sensor-cyan);
  border-radius: 50%;
  background: var(--paper);
  opacity: 0.42;
}

.node-one {
  top: 30%;
  right: 6%;
}

.node-two {
  left: 8%;
  bottom: 12%;
}

.studio-header {
  width: min(1780px, calc(100% - 40px));
  margin: 20px auto 0;
  padding: 18px 22px 20px;
  border: 1px solid rgba(156, 183, 173, 0.76);
  border-radius: 22px 22px 8px 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 40px rgba(20, 55, 58, 0.08);
  backdrop-filter: blur(18px);
}

.header-topline,
.title-row,
.studio-toolbar,
.panel-heading,
.studio-footer {
  display: flex;
  align-items: center;
}

.header-topline {
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--board-ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.back-link span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: 18px;
}

.demo-boundary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #78402f;
  font-size: 13px;
  font-weight: 700;
}

.demo-boundary span {
  color: var(--season-gold);
  font-size: 12px;
}

.title-row {
  gap: 18px;
  padding: 18px 2px 16px;
}

.program-seal {
  display: grid;
  flex: 0 0 76px;
  width: 76px;
  height: 76px;
  place-items: center;
  border: 2px solid var(--board-ink);
  border-radius: 18px 18px 18px 4px;
  color: var(--board-ink);
  background: linear-gradient(145deg, #f8fbf7, #e6efe8);
  box-shadow: inset 0 0 0 5px rgba(23, 59, 64, 0.055);
}

.program-seal span {
  margin-bottom: -13px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.25em;
}

.program-seal strong {
  font-family: var(--display);
  font-size: 38px;
  font-weight: 600;
}

.title-copy {
  min-width: 0;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--sensor-cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.title-copy h1 {
  margin: 4px 0 2px;
  color: var(--board-ink);
  font-family: var(--display);
  font-size: clamp(30px, 3.1vw, 48px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.02em;
}

.title-copy h1 span {
  color: var(--season-gold);
}

.title-copy > p:last-child {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.workspace-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(86px, 1fr));
  gap: 8px;
  margin-left: auto;
}

.workspace-facts div {
  min-width: 94px;
  padding: 10px 12px;
  border-left: 3px solid var(--sensor-cyan);
  background: var(--panel-soft);
}

.workspace-facts span,
.workspace-facts strong {
  display: block;
}

.workspace-facts span {
  color: var(--muted);
  font-size: 11px;
}

.workspace-facts strong {
  margin-top: 3px;
  color: var(--board-ink);
  font-family: var(--utility);
  font-size: 14px;
}

.logic-rail {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--board-ink);
  border-radius: 10px;
  color: #f5f7f1;
  background: var(--board-ink);
  list-style: none;
}

.logic-rail::before {
  position: absolute;
  top: 25px;
  right: 10%;
  left: 10%;
  height: 1px;
  content: "";
  background: rgba(242, 189, 98, 0.36);
}

.logic-rail li {
  position: relative;
  display: grid;
  min-height: 58px;
  grid-template-columns: 30px auto;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  column-gap: 7px;
  padding: 10px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.13);
}

.logic-rail li:last-child {
  border-right: 0;
}

.logic-rail li[data-stage="safety"] {
  background: rgba(198, 71, 63, 0.28);
}

.logic-rail span {
  z-index: 1;
  display: grid;
  width: 27px;
  height: 27px;
  grid-row: 1 / 3;
  place-items: center;
  border: 1px solid rgba(242, 189, 98, 0.8);
  border-radius: 50%;
  color: var(--season-light);
  background: var(--board-ink);
  font-family: var(--utility);
  font-size: 10px;
}

.logic-rail strong {
  align-self: end;
  font-size: 13px;
}

.logic-rail small {
  align-self: start;
  color: #b9cfca;
  font-size: 10px;
}

.studio-toolbar {
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
}

.tool-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tool-button,
.copy-button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--board-ink);
  background: #f8faf7;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.tool-button {
  padding: 8px 12px;
}

.tool-button:hover,
.copy-button:hover {
  transform: translateY(-1px);
  border-color: var(--sensor-cyan);
  background: #edf5f2;
}

.tool-button.is-primary {
  border-color: var(--board-ink);
  color: #fff;
  background: var(--board-ink);
}

.studio-main {
  display: grid;
  width: min(1780px, calc(100% - 40px));
  grid-template-columns: minmax(0, 2fr) minmax(340px, 0.92fr);
  gap: 14px;
  margin: 14px auto;
}

.workspace-panel,
.output-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
}

.workspace-panel {
  border-radius: 8px 8px 8px 22px;
}

.output-panel {
  border-radius: 8px 8px 22px 8px;
}

.panel-heading {
  min-height: 72px;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  margin: 2px 0 0;
  color: var(--board-ink);
  font-size: 20px;
  line-height: 1.2;
}

.panel-note {
  max-width: 29rem;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.workspace-shell {
  position: relative;
  height: 660px;
  min-height: 520px;
  background: #edf3ee;
}

#blockly-workspace {
  position: absolute;
  inset: 0;
}

.loading-card,
.error-card {
  position: absolute;
  z-index: 4;
  top: 50%;
  left: 50%;
  width: min(360px, calc(100% - 40px));
  padding: 24px;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.loading-mark {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: var(--board-ink);
  font-family: var(--display);
  font-size: 28px;
}

.loading-card strong,
.error-card strong {
  color: var(--board-ink);
}

.loading-card p,
.error-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.error-card {
  border-color: rgba(198, 71, 63, 0.55);
}

.output-heading {
  min-height: 72px;
}

.copy-button {
  padding: 7px 10px;
}

.block-inspector {
  min-height: 92px;
  margin: 14px 16px 10px;
  padding: 12px 14px;
  border-left: 4px solid var(--season-gold);
  background: #f3f5ec;
}

.block-inspector span,
.block-inspector strong,
.block-inspector p {
  display: block;
}

.block-inspector span {
  color: var(--season-gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.block-inspector strong {
  margin-top: 4px;
  color: var(--board-ink);
  font-size: 13px;
}

.block-inspector p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.output-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 16px;
  border-bottom: 1px solid var(--line);
}

.output-tabs button {
  min-height: 42px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.output-tabs button[aria-selected="true"] {
  border-bottom-color: var(--sensor-cyan);
  color: var(--board-ink);
}

.output-content {
  height: 418px;
  margin: 0 16px;
  overflow: auto;
  background: #f7f9f6;
}

.output-content[hidden] {
  display: none;
}

.output-content pre {
  min-height: 100%;
  margin: 0;
  padding: 16px;
  overflow: visible;
  color: #284448;
  font-family: var(--utility);
  font-size: 11.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 2;
}

#cpp-output {
  color: #d7e7df;
  background: var(--board-deep);
}

#cpp-panel {
  background: var(--board-deep);
}

.truth-card {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 67px;
  margin: 12px 16px 16px;
  padding: 10px 12px;
  border: 1px solid rgba(198, 71, 63, 0.3);
  background: rgba(198, 71, 63, 0.065);
}

.truth-card > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--safety-red);
  border-radius: 50%;
  color: var(--safety-red);
  font-family: var(--display);
  font-size: 19px;
}

.truth-card p {
  margin: 0;
  color: #75524d;
  font-size: 10.5px;
  line-height: 1.5;
}

.truth-card strong {
  color: var(--safety-red);
}

.studio-footer {
  width: min(1780px, calc(100% - 40px));
  min-height: 48px;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 20px;
  padding: 10px 16px;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 11px;
}

.studio-footer p {
  margin: 0;
}

.studio-footer code {
  font-family: var(--utility);
}

/* Blockly is intentionally integrated into the project's material language. */
.blocklySvg {
  background-color: #edf3ee !important;
}

.blocklyToolboxDiv {
  width: 156px !important;
  border-right: 1px solid var(--line-strong);
  background: #f9fbf8 !important;
  box-shadow: 8px 0 24px rgba(20, 55, 58, 0.06);
}

.blocklyTreeRow {
  height: 40px !important;
  margin: 4px 8px !important;
  padding: 0 10px !important;
  border-left: 4px solid transparent !important;
  border-radius: 6px;
  line-height: 40px !important;
}

.blocklyTreeSelected {
  background-color: #e1ece7 !important;
}

.blocklyTreeLabel {
  color: var(--board-ink) !important;
  font-family: var(--body) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
}

.blocklyFlyoutBackground {
  fill: #f2f6f2 !important;
  fill-opacity: 0.98 !important;
}

.blocklyText,
.blocklyHtmlInput {
  font-family: var(--body) !important;
}

.blocklyScrollbarHandle {
  fill: #829f96 !important;
}

.blocklyZoom > image,
.blocklyTrash > image {
  opacity: 0.72;
}

@media (max-width: 1180px) {
  .studio-main {
    grid-template-columns: minmax(0, 1fr) 360px;
  }

  .workspace-facts {
    display: none;
  }

  .file-tools {
    width: 100%;
  }

  .studio-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 900px) {
  .studio-header,
  .studio-main,
  .studio-footer {
    width: min(100% - 24px, 780px);
  }

  .studio-main {
    grid-template-columns: 1fr;
  }

  .workspace-shell {
    height: 620px;
  }

  .output-content {
    height: 480px;
  }

  .logic-rail {
    grid-template-columns: 1fr;
  }

  .logic-rail::before {
    display: none;
  }

  .logic-rail li {
    min-height: 44px;
    grid-template-columns: 30px 1fr auto;
    grid-template-rows: 1fr;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }

  .logic-rail li:last-child {
    border-bottom: 0;
  }

  .logic-rail span {
    grid-row: 1;
  }

  .logic-rail strong,
  .logic-rail small {
    align-self: center;
  }
}

@media (max-width: 620px) {
  .studio-header {
    margin-top: 10px;
    padding: 13px;
    border-radius: 16px 16px 6px 6px;
  }

  .header-topline,
  .title-row,
  .panel-heading,
  .studio-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-topline {
    gap: 10px;
  }

  .demo-boundary {
    align-items: flex-start;
    font-size: 11px;
  }

  .title-row {
    gap: 10px;
  }

  .program-seal {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
  }

  .program-seal span {
    display: none;
  }

  .program-seal strong {
    font-size: 28px;
  }

  .title-copy h1 {
    font-size: 31px;
  }

  .title-copy > p:last-child {
    font-size: 12px;
  }

  .logic-rail li {
    grid-template-columns: 28px 1fr;
  }

  .logic-rail small {
    display: none;
  }

  .tool-group,
  .tool-button {
    width: 100%;
  }

  .tool-button {
    min-height: 42px;
  }

  .panel-heading {
    min-height: 0;
    padding: 13px;
  }

  .panel-note {
    text-align: left;
  }

  .workspace-shell {
    height: 590px;
  }

  .blocklyToolboxDiv {
    width: 128px !important;
  }

  .blocklyTreeRow {
    margin-right: 4px !important;
    margin-left: 4px !important;
    padding: 0 6px !important;
  }

  .blocklyTreeLabel {
    font-size: 11px !important;
  }

  .output-heading .copy-button {
    width: 100%;
  }

  .output-content {
    height: 520px;
    margin-right: 10px;
    margin-left: 10px;
  }

  .output-tabs,
  .block-inspector,
  .truth-card {
    margin-right: 10px;
    margin-left: 10px;
  }

  .studio-footer {
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
