.xrd-frame {
  background: #e8ebf3;
}

.xrd-lab {
  background:
    radial-gradient(
      circle at 12% 10%,
      rgba(83, 84, 168, 0.12),
      transparent 30%
    ),
    linear-gradient(135deg, #fbfbfe 0%, #f2f4f9 62%, #edf1f7 100%);
}

.xrd-heading {
  min-height: 56px;
  display: flex;
  align-items: center;
}

.xrd-heading h1 {
  font-size: 34px;
  line-height: 1.2;
  white-space: nowrap;
}

.xrd-main {
  grid-template-columns: minmax(0, 1.13fr) minmax(410px, 0.87fr);
}

.xrd-crystal-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) 68px;
}

.xrd-crystal-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(
      circle at 52% 48%,
      rgba(80, 104, 173, 0.36),
      transparent 38%
    ),
    linear-gradient(145deg, #10162e 0%, #17203e 55%, #0b1022 100%);
}

#xrd-crystal-canvas,
#xrd-detector-canvas,
#xrd-pattern-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.xrd-beam-label,
.xrd-plane-readout,
.xrd-bragg-card {
  position: absolute;
  z-index: 4;
  border: 1px solid rgba(195, 208, 244, 0.24);
  border-radius: 8px;
  background: rgba(11, 17, 36, 0.8);
  color: white;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(5px);
}

.xrd-beam-label {
  top: 15px;
  left: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
}

.xrd-beam-label > i {
  width: 30px;
  height: 3px;
  border-radius: 3px;
  background: #75e8ff;
  box-shadow: 0 0 10px rgba(117, 232, 255, 0.9);
}

.xrd-beam-label span {
  display: grid;
  gap: 2px;
}

.xrd-beam-label b {
  color: #d8f8ff;
  font-size: 13px;
}

.xrd-beam-label small {
  color: #aebfe4;
  font-size: 12px;
}

.xrd-plane-readout {
  bottom: 15px;
  left: 15px;
  max-width: 285px;
  display: grid;
  gap: 3px;
  padding: 10px 13px;
}

.xrd-plane-readout span,
.xrd-bragg-card span {
  color: #9caed8;
  font-size: 12px;
}

.xrd-plane-readout strong {
  color: #9ef1ff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
}

.xrd-plane-readout small,
.xrd-bragg-card small {
  color: #c0cae1;
  font-size: 12px;
  line-height: 1.4;
}

.xrd-bragg-card {
  right: 15px;
  bottom: 15px;
  display: grid;
  justify-items: end;
  gap: 3px;
  padding: 10px 13px;
}

.xrd-bragg-card strong {
  color: #ffe6a3;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
}

.xrd-scan-flash {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    circle at 56% 48%,
    rgba(126, 240, 255, 0.4),
    transparent 18%
  );
  opacity: 0;
}

.xrd-scan-flash.flash {
  animation: xrdFlash 480ms ease-out;
}

@keyframes xrdFlash {
  0% {
    opacity: 0;
  }
  28% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.xrd-lattice-readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid #dfe4ec;
  background: #fbfcfe;
}

.xrd-lattice-readout > div {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  border-right: 1px solid #e2e6ed;
}

.xrd-lattice-readout > div:last-child {
  border-right: 0;
}

.xrd-lattice-readout small {
  color: #758091;
  font-size: 12px;
}

.xrd-lattice-readout strong {
  color: #3f4975;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 16px;
}

.xrd-dashboard {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(174px, 1.08fr) minmax(144px, 0.92fr) auto;
  gap: 10px;
}

.xrd-detector-panel,
.xrd-pattern-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.xrd-detector-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(
      circle at 50% 50%,
      rgba(88, 117, 194, 0.21),
      transparent 45%
    ),
    #0d1429;
}

.xrd-detector-coordinate {
  position: absolute;
  right: 10px;
  bottom: 7px;
  color: rgba(199, 211, 241, 0.68);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.xrd-pattern-panel {
  background: #ffffff;
}

.xrd-identification {
  min-height: 84px;
  display: grid;
  grid-template-columns: 98px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border: 1px solid #d6dbe8;
  border-left: 4px solid #8a91a9;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  transition:
    border-color 260ms ease,
    background 260ms ease,
    transform 260ms ease;
}

.xrd-identification > span {
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 7px 9px;
  border-radius: 7px;
  background: #eef0f5;
  color: #687184;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.xrd-identification > div {
  min-width: 0;
}

.xrd-identification small {
  display: block;
  margin-bottom: 2px;
  color: #798394;
  font-size: 12px;
}

.xrd-identification strong {
  display: block;
  overflow: hidden;
  color: #30394b;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xrd-identification p {
  margin: 4px 0 0;
  color: #687486;
  font-size: 12px;
  line-height: 1.45;
}

.xrd-identification.scanning {
  border-left-color: #5b5bd6;
  background: #f7f7ff;
}

.xrd-identification.scanning > span {
  background: #e7e7fb;
  color: #5051ba;
}

.xrd-identification.identified {
  border-color: #9fd5ca;
  border-left-color: #168b79;
  background: #f2fbf8;
  transform: translateY(-2px);
}

.xrd-identification.identified > span {
  background: #dff4ee;
  color: #137866;
}

.xrd-identification.identified strong {
  color: #146f63;
}

.xrd-controls {
  grid-template-columns:
    minmax(390px, 1.25fr) minmax(160px, 0.52fr) minmax(160px, 0.52fr)
    auto;
}

.xrd-presets {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.xrd-presets button {
  min-width: 0;
  min-height: 48px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid #d3d9e5;
  border-radius: 8px;
  background: white;
  color: #515d71;
}

.xrd-presets button b {
  font-size: 13px;
}

.xrd-presets button small {
  color: #8791a3;
  font-size: 12px;
}

.xrd-presets button.active {
  border-color: #5b5bd6;
  background: #ececfc;
  color: #494ab4;
  box-shadow: inset 0 0 0 1px rgba(91, 91, 214, 0.16);
}

.xrd-presets button.active small {
  color: #6061bb;
}

.prompt-panel .xrd-takeaway {
  position: relative;
  z-index: 5;
  right: auto;
  bottom: auto;
  width: 100%;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border-color: #aaaaf0;
  background: #f0f0ff;
  box-shadow: 0 12px 28px rgba(75, 77, 173, 0.12);
}

.prompt-panel .xrd-takeaway > span {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 7px;
  font-size: 18px;
  line-height: 1.18;
  text-align: left;
}

.prompt-panel .xrd-takeaway > span small {
  color: #7778bb;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.xrd-takeaway-body {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.prompt-panel .xrd-read-steps {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
}

.prompt-panel .xrd-read-steps p {
  min-width: 0;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  margin: 0;
}

.prompt-panel .xrd-read-steps b {
  color: #4b4dad;
  font-size: 13px;
}

.prompt-panel .xrd-read-steps span {
  color: #586477;
  font-size: 12px;
  line-height: 1.38;
}

.prompt-panel .xrd-takeaway .xrd-final-verdict {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid #cfd0f4;
  color: #3f4960;
  font-size: 12.5px;
  line-height: 1.42;
}

.prompt-panel .xrd-takeaway .xrd-final-verdict b {
  color: #16806f;
}

body[data-theme="diffraction"] .prompt-panel .progress-block {
  margin-top: 14px;
  padding-top: 0;
}

body.show-experiment-conclusion .xrd-identification {
  box-shadow: 0 13px 28px rgba(22, 139, 121, 0.13);
}

@media (max-width: 1450px), (max-height: 820px) {
  .xrd-heading {
    min-height: 42px;
  }

  .xrd-heading h1 {
    font-size: 26px;
  }

  .xrd-main {
    grid-template-columns: minmax(0, 1.08fr) minmax(370px, 0.92fr);
    gap: 8px;
  }

  .xrd-crystal-panel {
    grid-template-rows: auto minmax(0, 1fr) 56px;
  }

  .xrd-plane-readout,
  .xrd-bragg-card {
    bottom: 9px;
    padding: 7px 9px;
  }

  .xrd-plane-readout {
    left: 9px;
    max-width: 240px;
  }

  .xrd-bragg-card {
    right: 9px;
  }

  .xrd-plane-readout strong,
  .xrd-bragg-card strong {
    font-size: 14px;
  }

  .xrd-plane-readout small,
  .xrd-bragg-card small {
    font-size: 12px;
  }

  .xrd-beam-label {
    top: 9px;
    left: 9px;
    padding: 7px 9px;
  }

  .xrd-dashboard {
    grid-template-rows: minmax(145px, 1.02fr) minmax(125px, 0.88fr) auto;
    gap: 7px;
  }

  .xrd-identification {
    min-height: 68px;
    grid-template-columns: 78px minmax(0, 1fr);
    gap: 9px;
    padding: 8px 10px;
  }

  .xrd-identification strong {
    font-size: 14px;
  }

  .xrd-identification p {
    margin-top: 2px;
    font-size: 12px;
  }

  .xrd-lattice-readout strong {
    font-size: 13px;
  }

  .xrd-controls {
    grid-template-columns:
      minmax(335px, 1.2fr) minmax(140px, 0.55fr) minmax(140px, 0.55fr)
      auto;
  }

  .xrd-presets button {
    min-height: 42px;
    padding: 4px 5px;
  }

  .xrd-presets button b,
  .xrd-presets button small {
    font-size: 12px;
  }

  .prompt-panel .xrd-takeaway {
    gap: 4px;
    margin-top: 8px;
    padding: 8px 9px;
  }

  .prompt-panel .xrd-takeaway > span {
    font-size: 12.5px;
  }

  .prompt-panel .xrd-takeaway > span small,
  .prompt-panel .xrd-read-steps {
    display: none;
  }

  .prompt-panel .xrd-takeaway-body {
    gap: 3px;
  }

  .prompt-panel .xrd-takeaway .xrd-final-verdict {
    border-top: 0;
    font-size: 10.5px;
    line-height: 1.35;
    padding-top: 0;
  }

  body[data-theme="diffraction"] .prompt-panel .progress-block {
    margin-top: auto;
    padding-top: 8px;
  }
}
body[data-theme="diffraction"].presentation-mode .build-overlay {
  transition: none;
}

body[data-theme="diffraction"].presentation-mode .lab-content {
  transition: none;
}
body[data-theme="diffraction"] {
  --figure-accent: #5557b8;
  --figure-accent-soft: #ececfc;
}
