/* Shared right-side content zoom control */
:root {
  --experiment-ui-font: "Source Han Sans CN", "Noto Sans CJK SC", sans-serif;
  --experiment-code-font: "Consolas", "Courier New", monospace;
}

body,
body * {
  font-family: var(--experiment-ui-font) !important;
}

body code,
body code *,
body pre,
body pre *,
body kbd,
body kbd *,
body samp,
body samp *,
body .console,
body .console *,
body .dig-terminal,
body .dig-terminal *,
body .serial-terminal,
body .serial-terminal *,
body .terminal-output,
body .terminal-output *,
body [class~="mono"],
body [class~="mono"] *,
body [class$="-mono"],
body [class$="-mono"] *,
body [class^="code-"],
body [class^="code-"] *,
body [class$="-code"],
body [class$="-code"] *,
body [class*="-code-"],
body [class*="-code-"] *,
body .command-content,
body .command-content *,
body .hex-area,
body .hex-area *,
body .hex-input,
body .cell-hex,
body .uid-value-hex,
body .byte-hex,
body .hex-byte,
body .block-data-hex,
body .mqtt-hex,
body .mqtt-byte-hex,
body .uid-binary-code {
  font-family: var(--experiment-code-font) !important;
}

[hidden] {
  display: none !important;
}

/* Dynamic text fallback; source declarations are normalized separately. */
.page-min-font-size {
  font-size: 14px !important;
}

.page-zoom-enabled main.main > :not(.canvas-toolbar):not(.page-toolbar) {
  zoom: var(--page-content-zoom, 1);
}

.page-corner-controls {
  position: fixed;
  right: 22px;
  bottom: 18px;
  z-index: 1100;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-zoom-control {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--page-zoom-accent-border, rgba(37, 99, 235, .28));
  border-radius: 10px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .16);
  backdrop-filter: blur(10px);
}

.page-zoom-control:hover,
.page-zoom-control:focus-within {
  background:
    linear-gradient(
      var(--page-zoom-accent-soft, rgba(37, 99, 235, .08)),
      var(--page-zoom-accent-soft, rgba(37, 99, 235, .08))
    ),
    #fff;
}

.page-document-button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: auto !important;
  min-width: 104px;
  height: 48px;
  margin: 0 !important;
  padding: 0 14px !important;
  border: 1px solid var(--page-zoom-accent-border, rgba(37, 99, 235, .28)) !important;
  border-radius: 10px !important;
  background: rgba(255, 255, 255, .94) !important;
  color: var(--page-zoom-accent-dark, #1d4ed8) !important;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .16);
  font-family: inherit;
  font-size: 14px !important;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.page-document-button:hover {
  background:
    linear-gradient(
      var(--page-zoom-accent-soft, rgba(37, 99, 235, .08)),
      var(--page-zoom-accent-soft, rgba(37, 99, 235, .08))
    ),
    #fff !important;
}

.page-document-button svg {
  flex: 0 0 16px;
  width: 16px !important;
  height: 16px !important;
  stroke: currentColor !important;
}

.page-experiment-title {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  margin: 0 0 14px;
  padding: 2px 4px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, .24);
  color: #0f172a;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
  overflow-wrap: anywhere;
}

.page-zoom-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex: 0 0 auto;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--page-zoom-accent-dark, #1d4ed8);
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  cursor: default;
}

.page-zoom-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: max-width .22s ease, opacity .18s ease;
}

.page-zoom-control:hover .page-zoom-panel,
.page-zoom-control:focus-within .page-zoom-panel {
  width: auto;
  max-width: 260px;
  opacity: 1;
  pointer-events: auto;
}

.page-zoom-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--page-zoom-accent-border, rgba(37, 99, 235, .28));
  border-radius: 6px;
  background: var(--page-zoom-accent-soft, rgba(37, 99, 235, .08));
  color: var(--page-zoom-accent-dark, #1d4ed8);
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.page-zoom-btn:hover {
  background: var(--page-zoom-accent-hover, rgba(37, 99, 235, .16));
}

.page-zoom-slider {
  box-sizing: border-box;
  width: 132px !important;
  min-width: 132px;
  height: 4px !important;
  min-height: 4px !important;
  margin: 0;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 999px;
  background: rgba(37, 99, 235, .2) !important;
  appearance: none;
  -webkit-appearance: none;
  accent-color: var(--page-zoom-accent, #2563eb);
}

.page-zoom-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(37, 99, 235, .2);
}

.page-zoom-slider::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 0;
  border-radius: 50%;
  background: var(--page-zoom-accent, #2563eb);
  box-shadow: 0 2px 6px rgba(37, 99, 235, .35);
  cursor: pointer;
  -webkit-appearance: none;
}

.page-zoom-slider::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: 999px;
  background: rgba(37, 99, 235, .2);
}

.page-zoom-slider::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--page-zoom-accent, #2563eb);
}

.page-zoom-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--page-zoom-accent, #2563eb);
  box-shadow: 0 2px 6px rgba(37, 99, 235, .35);
  cursor: pointer;
}

.page-zoom-value {
  min-width: 42px;
  color: #475569;
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}

.page-side-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, .22);
}

.page-side-actions > button,
.page-side-action-button {
  width: 112px !important;
  min-width: 112px;
  max-width: 100%;
  height: 34px;
  padding: 0 12px !important;
  font-size: 14px !important;
  justify-content: center;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .page-corner-controls {
    right: 12px;
    bottom: 12px;
  }

  .page-document-button {
    min-width: 96px;
    padding: 0 12px !important;
  }

  .page-zoom-control .page-zoom-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    box-sizing: border-box;
    padding: 8px;
    border: 1px solid rgba(148, 163, 184, .32);
    border-radius: 10px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 12px 30px rgba(15, 23, 42, .16);
  }

  .page-zoom-control:hover .page-zoom-panel,
  .page-zoom-control:focus-within .page-zoom-panel {
    width: min(260px, calc(100vw - 24px));
  }
}

@media (max-width: 760px) {
  .page-zoom-enabled .app {
    flex-direction: column;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .page-zoom-enabled .app > .enc-panel {
    flex: 0 0 auto;
    width: 100%;
    max-height: 45vh;
    border-right: 0;
    border-bottom: 1px solid rgba(148, 163, 184, .28);
    overflow-y: auto;
  }

  .page-zoom-enabled .app > main.main {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    min-height: 100vh;
    padding: 16px 14px 96px !important;
    overflow-x: auto;
    overflow-y: visible;
  }
}

#introModal.page-intro-floating-mask {
  background: transparent !important;
  backdrop-filter: none !important;
  pointer-events: none !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
}

#introModal.page-intro-floating-mask.show,
#introModal.page-intro-floating-mask[style*="display: flex"],
#introModal.page-intro-floating-mask[style*="display: block"] {
  display: block !important;
}

#introModal.page-intro-floating-mask .page-intro-floating-dialog {
  position: fixed !important;
  right: auto !important;
  bottom: auto !important;
  min-width: 360px;
  min-height: 160px;
  max-width: none !important;
  max-height: calc(100vh - 24px) !important;
  resize: none;
  overflow: hidden;
  pointer-events: auto;
  animation: none !important;
}

#introModal.page-intro-floating-mask .page-intro-floating-dialog .modal-hd {
  cursor: move;
  user-select: none;
}

#introModal.page-intro-floating-mask .page-intro-floating-dialog .modal-bd {
  max-height: calc(100% - 58px) !important;
  overflow: auto;
  font-size: 16px;
  zoom: var(--intro-content-zoom, 1);
}

#introModal.page-intro-floating-mask .page-intro-floating-dialog .modal-bd h3 {
  font-size: 16px;
}

.page-intro-zoom-control {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, .32);
  border-radius: 10px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .16);
  backdrop-filter: blur(10px);
  pointer-events: auto;
}

.page-intro-zoom-control:hover .page-zoom-panel,
.page-intro-zoom-control:focus-within .page-zoom-panel {
  width: auto;
  max-width: 260px;
  opacity: 1;
  pointer-events: auto;
}

#introModal.page-intro-floating-mask .page-intro-floating-dialog.page-intro-minimized {
  height: 44px !important;
  min-height: 44px;
  resize: none;
}

#introModal.page-intro-floating-mask .page-intro-floating-dialog.page-intro-minimized .modal-bd {
  display: none;
}

.page-intro-minimize {
  margin-left: auto;
}

.page-intro-resize-handle {
  position: absolute;
  z-index: 5;
  background: transparent;
}

.page-intro-resize-n,
.page-intro-resize-s {
  left: 10px;
  right: 10px;
  height: 8px;
  cursor: ns-resize;
}

.page-intro-resize-n { top: -4px; }
.page-intro-resize-s { bottom: -4px; }

.page-intro-resize-e,
.page-intro-resize-w {
  top: 10px;
  bottom: 10px;
  width: 8px;
  cursor: ew-resize;
}

.page-intro-resize-e { right: -4px; }
.page-intro-resize-w { left: -4px; }

.page-intro-resize-ne,
.page-intro-resize-nw,
.page-intro-resize-se,
.page-intro-resize-sw {
  width: 14px;
  height: 14px;
}

.page-intro-resize-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.page-intro-resize-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.page-intro-resize-se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.page-intro-resize-sw { left: -5px; bottom: -5px; cursor: nesw-resize; }

.page-intro-minimized .page-intro-resize-handle {
  display: none;
}

.page-intro-minimized .page-intro-zoom-control {
  display: none;
}

/* Keep every experiment introduction aligned with the first two experiment pages. */
#introModal .modal-hd {
  padding: 14px 18px;
}

#introModal .modal-hd .title {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0;
}

#introModal .modal-bd,
#introModal.page-intro-floating-mask .page-intro-floating-dialog .modal-bd {
  padding: 16px 20px 20px;
  color: #334155;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.85;
  letter-spacing: 0;
}

#introModal .modal-bd h3,
#introModal.page-intro-floating-mask .page-intro-floating-dialog .modal-bd h3 {
  margin: 10px 0 6px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: 0;
}

#introModal .modal-bd h3:first-child {
  margin-top: 0;
}

#introModal .modal-bd h4,
#introModal .modal-bd .intro-subtitle {
  margin: 8px 0 4px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.6;
  letter-spacing: 0;
}

#introModal .modal-bd h5,
#introModal .modal-bd h6 {
  margin: 7px 0 4px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0;
}

#introModal .modal-bd ul,
#introModal .modal-bd ol {
  margin: 0 0 4px;
  padding-left: 22px;
  font-size: inherit;
  line-height: inherit;
}

#introModal .modal-bd li {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.85;
  letter-spacing: 0;
}

#introModal .modal-bd p,
#introModal .modal-bd dt,
#introModal .modal-bd dd,
#introModal .modal-bd figcaption {
  margin-top: 0;
  font-size: 16px;
  line-height: 1.85;
  letter-spacing: 0;
}

#introModal .modal-bd p {
  margin-bottom: 6px;
}

#introModal .modal-bd code,
#introModal .modal-bd pre,
#introModal .modal-bd kbd,
#introModal .modal-bd samp {
  font-size: 14px;
  line-height: 1.65;
  letter-spacing: 0;
}

/* Inline API names in prose use the same typeface as the surrounding sentence. */
#introModal .modal-bd p code,
#introModal .modal-bd li code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

#introModal .modal-bd table {
  display: inline-table;
  width: auto;
  max-width: 100%;
  table-layout: auto;
  margin: 8px 0 10px;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0;
}

#introModal .modal-bd table th,
#introModal .modal-bd table td {
  width: auto;
  padding: 7px 9px;
  font-size: 14px;
  line-height: 1.55;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
}

#introModal .modal-bd table th {
  font-weight: 700;
  white-space: nowrap;
}

#introModal .modal-bd table .long-text {
  white-space: normal;
  word-break: break-word;
}

@media (max-width: 640px) {
  #introModal .modal-bd,
  #introModal.page-intro-floating-mask .page-intro-floating-dialog .modal-bd {
    padding: 14px 16px 18px;
  }

  #introModal .modal-bd table th {
    white-space: normal;
  }
}
