.crypto-demo {
  margin: 1.5rem 0;
}

.crypto-demo .demo-card {
  border: 1px solid var(--card-border, rgba(64, 92, 122, 0.22));
  border-radius: 8px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(6px);
}

[data-theme="dark"] .crypto-demo .demo-card {
  background: rgba(20, 28, 36, 0.72);
}

.crypto-demo .demo-title {
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
}

.crypto-demo .demo-copy {
  margin: 0 0 0.75rem;
  color: var(--font-color);
}

.crypto-demo .demo-note {
  margin: 0 0 0.9rem;
  padding: 0.7rem 0.8rem;
  border-left: 3px solid var(--theme-color, #174c80);
  background: rgba(23, 76, 128, 0.06);
  border-radius: 6px;
}

.crypto-demo .demo-field {
  display: block;
  margin-bottom: 0.85rem;
}

.crypto-demo .demo-label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.crypto-demo .demo-input,
.crypto-demo .demo-output {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--card-border, rgba(64, 92, 122, 0.22));
  border-radius: 8px;
  padding: 0.75rem;
  font: inherit;
  color: inherit;
  background: rgba(255, 255, 255, 0.86);
}

[data-theme="dark"] .crypto-demo .demo-input,
[data-theme="dark"] .crypto-demo .demo-output {
  background: rgba(9, 14, 20, 0.86);
}

.crypto-demo .demo-input {
  min-height: 5.5rem;
  resize: vertical;
}

.crypto-demo .demo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.crypto-demo .demo-button {
  appearance: none;
  border: 1px solid var(--theme-color, #174c80);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--theme-color, #174c80);
  cursor: pointer;
}

.crypto-demo .demo-button:hover:not(:disabled) {
  background: #143c67;
}

.crypto-demo .demo-button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.crypto-demo .demo-output {
  min-height: 10rem;
  white-space: pre-wrap;
  overflow-x: auto;
  margin: 0;
}

.crypto-demo .demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.crypto-demo .demo-panel {
  border: 1px solid var(--card-border, rgba(64, 92, 122, 0.22));
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.6);
}

[data-theme="dark"] .crypto-demo .demo-panel,
[data-theme="dark"] .crypto-demo .demo-step {
  background: rgba(9, 14, 20, 0.72);
}

.crypto-demo .demo-panel-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.crypto-demo .demo-panel-copy {
  margin: 0;
}

.crypto-demo .demo-list {
  margin: 0 0 0.85rem;
  padding-left: 1.15rem;
}

.crypto-demo .demo-list li + li {
  margin-top: 0.35rem;
}

.crypto-demo .demo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.crypto-demo .demo-tab {
  appearance: none;
  border: 1px solid var(--card-border, rgba(64, 92, 122, 0.28));
  border-radius: 8px;
  padding: 0.52rem 0.8rem;
  font: inherit;
  font-weight: 600;
  color: inherit;
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
}

[data-theme="dark"] .crypto-demo .demo-tab {
  background: rgba(9, 14, 20, 0.78);
}

.crypto-demo .demo-tab.is-active {
  border-color: var(--theme-color, #174c80);
  color: var(--theme-color, #174c80);
}

.crypto-demo .demo-flow {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.crypto-demo .demo-step {
  border: 1px solid var(--card-border, rgba(64, 92, 122, 0.22));
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.58);
}

.crypto-demo .demo-step.is-active {
  border-color: var(--theme-color, #174c80);
  box-shadow: inset 0 0 0 1px rgba(23, 76, 128, 0.18);
}

.crypto-demo .demo-step.is-done {
  opacity: 0.82;
}

.crypto-demo .demo-step-index {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--meta-color, #6f7f92);
  font-size: 0.88rem;
}

.crypto-demo .demo-step-title {
  display: block;
  margin-bottom: 0.22rem;
  font-weight: 600;
}

.crypto-demo .demo-step-copy {
  margin: 0;
}

.crypto-demo .demo-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.crypto-demo .demo-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--card-border, rgba(64, 92, 122, 0.26));
  border-radius: 8px;
  padding: 0.42rem 0.62rem;
  background: rgba(255, 255, 255, 0.76);
}

[data-theme="dark"] .crypto-demo .demo-chip {
  background: rgba(9, 14, 20, 0.78);
}

.crypto-demo .demo-meta {
  margin: 0 0 0.85rem;
  color: var(--meta-color, #6f7f92);
}

.public-key-flowchart {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 0.65rem;
  margin: 1.35rem 0;
}

.public-key-flowchart .flow-node {
  min-width: 0;
  border: 1px solid var(--card-border, rgba(64, 92, 122, 0.24));
  border-radius: 8px;
  padding: 0.85rem;
  background: rgba(255, 255, 255, 0.68);
}

[data-theme="dark"] .public-key-flowchart .flow-node {
  background: rgba(9, 14, 20, 0.72);
}

.public-key-flowchart .flow-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.55rem;
  height: 1.55rem;
  margin-bottom: 0.45rem;
  border-radius: 999px;
  color: #fff;
  background: var(--theme-color, #174c80);
  font-size: 0.86rem;
  font-weight: 700;
}

.public-key-flowchart strong {
  display: block;
  margin-bottom: 0.28rem;
}

.public-key-flowchart p {
  margin: 0;
  color: var(--meta-color, #6f7f92);
}

.public-key-flowchart .flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--theme-color, #174c80);
  font-weight: 700;
}

#article-container .crypto-demo .demo-number-grid,
.crypto-demo .demo-number-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  align-items: end;
}

#article-container .crypto-demo .demo-mini-field,
.crypto-demo .demo-mini-field {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.3rem;
  min-width: 0;
  margin: 0 !important;
  font-weight: 600;
  line-height: 1.35;
}

#article-container .crypto-demo .demo-mini-label,
.crypto-demo .demo-mini-label {
  display: block;
  color: var(--font-color);
  white-space: nowrap;
}

#article-container .crypto-demo .demo-number-input,
.crypto-demo .demo-number-input {
  display: block !important;
  width: 100% !important;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--card-border, rgba(64, 92, 122, 0.22));
  border-radius: 8px;
  margin: 0 !important;
  padding: 0.56rem 0.62rem;
  font: inherit;
  color: inherit;
  background: rgba(255, 255, 255, 0.86);
}

[data-theme="dark"] #article-container .crypto-demo .demo-number-input,
[data-theme="dark"] .crypto-demo .demo-number-input {
  background: rgba(9, 14, 20, 0.86) !important;
}

#article-container .crypto-demo .demo-kv-grid,
.crypto-demo .demo-kv-grid {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(8.5rem, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

#article-container .crypto-demo .demo-kv,
.crypto-demo .demo-kv {
  display: flex !important;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
  margin: 0 !important;
  border: 1px solid var(--card-border, rgba(64, 92, 122, 0.22));
  border-radius: 8px;
  padding: 0.62rem 0.7rem;
  background: rgba(255, 255, 255, 0.58);
}

[data-theme="dark"] #article-container .crypto-demo .demo-kv,
[data-theme="dark"] .crypto-demo .demo-kv {
  background: rgba(9, 14, 20, 0.72);
}

#article-container .crypto-demo .demo-kv strong,
.crypto-demo .demo-kv strong {
  display: block;
  color: var(--meta-color, #6f7f92);
  font-size: 0.86rem;
  line-height: 1.25;
}

#article-container .crypto-demo .demo-kv-value,
.crypto-demo .demo-kv-value {
  display: block;
  overflow-wrap: anywhere;
  font-family: "JetBrains Mono", "Cascadia Code", "IBM Plex Mono", Consolas, monospace;
  font-size: 0.94rem;
  line-height: 1.45;
}

@media (max-width: 768px) {
  .crypto-demo .demo-card {
    padding: 0.9rem;
  }

  .crypto-demo .demo-grid {
    grid-template-columns: 1fr;
  }

  #article-container .crypto-demo .demo-number-grid,
  #article-container .crypto-demo .demo-kv-grid,
  .crypto-demo .demo-number-grid,
  .crypto-demo .demo-kv-grid {
    grid-template-columns: 1fr;
  }

  .public-key-flowchart {
    grid-template-columns: 1fr;
  }

  .public-key-flowchart .flow-arrow {
    transform: rotate(90deg);
    min-height: 1.2rem;
  }

  .crypto-demo .demo-actions {
    flex-direction: column;
  }

  .crypto-demo .demo-button,
  .crypto-demo .demo-tab {
    width: 100%;
  }
}
