/* CSP-strict styles for arks interactive documentation widgets & builders. */
.arks-widget {
  margin: 1.5rem 0;
  padding: 1.25rem;
  border: 1px solid #d0d7de;
  border-radius: 10px;
  background: #f6f8fa;
  color: #1f2328;
}

.arks-widget-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.arks-widget-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.arks-widget-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(9, 105, 218, 0.12);
  color: #0969da;
}

.arks-widget-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.9rem;
}

.arks-widget-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem;
  max-width: 100%;
  padding: 0.18rem;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  background: #ffffff;
}

.arks-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.28rem 0.56rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: inherit;
  white-space: nowrap;
}

.arks-btn:hover {
  background: rgba(127, 127, 127, 0.12);
}

.arks-btn.is-active {
  background: #0969da;
  color: #ffffff;
}

.arks-btn:focus-visible,
.arks-chip:focus-visible,
.arks-copy-btn:focus-visible,
.arks-explorer-input:focus-visible,
.arks-builder-check input:focus-visible {
  outline: 2px solid #0969da;
  outline-offset: 2px;
}

.arks-sim-canvas {
  display: block;
  width: 100%;
  height: 260px;
  border-radius: 8px;
  border: 1px solid #d0d7de;
  background: #ffffff;
}

.arks-widget-note {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  opacity: 0.78;
}

.arks-explorer-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.85rem;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  background: #ffffff;
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  margin-bottom: 0.7rem;
}

.arks-explorer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.arks-chip {
  appearance: none;
  border: 1px solid #d0d7de;
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  font-size: 0.76rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  cursor: pointer;
  background: #ffffff;
  color: inherit;
}

.arks-chip:hover,
.arks-chip.is-active {
  border-color: #0969da;
  color: #0969da;
}

.arks-explorer-meta {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  opacity: 0.8;
}

.arks-explorer-result {
  padding: 0.9rem 1rem;
  border-radius: 8px;
  border: 1px solid #d0d7de;
  background: #ffffff;
  font-size: 0.88rem;
  line-height: 1.5;
}

.arks-status-verified {
  color: #1a7f37;
  font-weight: 700;
}

.arks-status-refuse {
  color: #cf222e;
  font-weight: 700;
}

.arks-builder-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.1rem;
  margin-bottom: 0.9rem;
  font-size: 0.84rem;
}

.arks-builder-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.arks-code-block {
  position: relative;
  margin-top: 0.6rem;
}

.arks-code-block > button:not(.arks-copy-btn) {
  display: none;
}

.arks-code-pre {
  margin: 0;
  padding: 0.85rem 4.75rem 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid #d0d7de;
  background: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}

.arks-copy-btn {
  position: absolute;
  top: 0.45rem;
  right: 0.5rem;
  z-index: 2;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  background: #f6f8fa;
  color: inherit;
}

.arks-copy-btn:hover {
  border-color: #0969da;
}

@media (max-width: 640px) {
  .arks-widget {
    padding: 0.95rem;
  }
  .arks-btn {
    min-height: 36px;
    padding: 0.38rem 0.62rem;
  }
  .arks-chip {
    min-height: 34px;
    padding: 0.28rem 0.65rem;
  }
  .arks-copy-btn {
    min-height: 32px;
  }
  .arks-sim-canvas {
    height: 360px;
  }
}

/* Dark theme via manual html[data-theme="dark"] OR OS preference when not forced light */
html[data-theme="dark"] .arks-widget {
  border-color: #30363d;
  background: #161b22;
  color: #e6edf3;
}
html[data-theme="dark"] .arks-widget-group,
html[data-theme="dark"] .arks-sim-canvas,
html[data-theme="dark"] .arks-explorer-input,
html[data-theme="dark"] .arks-chip,
html[data-theme="dark"] .arks-explorer-result,
html[data-theme="dark"] .arks-code-pre {
  border-color: #30363d;
  background: #0d1117;
}
html[data-theme="dark"] .arks-copy-btn {
  border-color: #30363d;
  background: #161b22;
}
html[data-theme="dark"] .arks-widget-badge {
  background: rgba(88, 166, 255, 0.16);
  color: #58a6ff;
}
html[data-theme="dark"] .arks-btn.is-active {
  background: #1f6feb;
}
html[data-theme="dark"] .arks-chip:hover,
html[data-theme="dark"] .arks-chip.is-active {
  border-color: #58a6ff;
  color: #58a6ff;
}
html[data-theme="dark"] .arks-status-verified { color: #3fb950; }
html[data-theme="dark"] .arks-status-refuse { color: #f85149; }

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .arks-widget {
    border-color: #30363d;
    background: #161b22;
    color: #e6edf3;
  }
  html:not([data-theme="light"]) .arks-widget-group,
  html:not([data-theme="light"]) .arks-sim-canvas,
  html:not([data-theme="light"]) .arks-explorer-input,
  html:not([data-theme="light"]) .arks-chip,
  html:not([data-theme="light"]) .arks-explorer-result,
  html:not([data-theme="light"]) .arks-code-pre {
    border-color: #30363d;
    background: #0d1117;
  }
  html:not([data-theme="light"]) .arks-copy-btn {
    border-color: #30363d;
    background: #161b22;
  }
  html:not([data-theme="light"]) .arks-widget-badge {
    background: rgba(88, 166, 255, 0.16);
    color: #58a6ff;
  }
  html:not([data-theme="light"]) .arks-btn.is-active {
    background: #1f6feb;
  }
  html:not([data-theme="light"]) .arks-chip:hover,
  html:not([data-theme="light"]) .arks-chip.is-active {
    border-color: #58a6ff;
    color: #58a6ff;
  }
  html:not([data-theme="light"]) .arks-status-verified { color: #3fb950; }
  html:not([data-theme="light"]) .arks-status-refuse { color: #f85149; }
}
