/* ── Pattern Lab: shared styles ──────────────────────────────────────────────
   What more than one panel draws with. Each panel's own classes live beside
   the panel (<Panel>.module.css) since 2026-09; a rule is here because two
   files use it, or because the shell (PatternLabClient) does. */

.labBrand {
  color: inherit;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.labBrand:hover {
  opacity: 0.8;
}

.labTitle {
  font-size: 12px;
  font-weight: 600;
  color: #8c8577;
  letter-spacing: 0.01em;
}

.projectIdentity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

.projectMeta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  min-height: 17px;
}

.labName {
  width: 100%;
  min-width: 0;
  padding: 3px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #171512;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
}

.labName::placeholder {
  color: #9a9486;
  font-weight: 400;
}

.labName:hover {
  background: rgba(255, 253, 248, 0.7);
  border-color: rgba(23, 21, 18, 0.18);
}

.labName:focus {
  outline: 2px solid #9b4827;
  outline-offset: 1px;
  background: #fffdf8;
}

.labNav {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  font-weight: 600;
}

.labNav a {
  color: #6b655a;
  text-decoration: none;
  transition: color 0.15s ease;
}

.labNav a:hover {
  color: #171512;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(23, 21, 18, 0.18);
}

.headerMeta,
.stats,
.actionRow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.headerMeta,
.stats,
.emptyState {
  color: rgba(23, 21, 18, 0.62);
  font-family: var(--font-jetbrains), monospace;
  font-size: 12px;
  line-height: 1.45;
  text-transform: uppercase;
}

.previewHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.editorHeader {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.stats {
  display: flex;
  text-transform: none;
  align-items: center;
  gap: 8px;
  color: rgba(23, 21, 18, 0.62);
  font-family: var(--font-jetbrains), monospace;
  font-size: 12px;
}

.dotSep {
  opacity: 0.4;
}

.headerToggle,
.headerSelect {
  appearance: none;
  min-height: 32px;
  border: 1px solid rgba(23, 21, 18, 0.22);
  background: #ffffff;
  color: #171512;
  padding: 0 10px;
  font-family: var(--font-inter), system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  border-radius: 5px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.headerToggle:hover,
.headerSelect:hover {
  border-color: #171512;
  background: #f7f3ea;
}

.saveStatus {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #6b655a;
  font-size: 11px;
  line-height: 17px;
  white-space: nowrap;
}

.saveDot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #68826b;
  flex: none;
}

.saveStatus[data-state="pending"] .saveDot,
.saveStatus[data-state="idle"] .saveDot {
  background: #a58a56;
}

.saveStatus[data-state="error"] {
  color: #b42318;
}

.saveStatus[data-state="error"] .saveDot {
  background: currentColor;
}

.headerToggle[data-primary="true"] {
  background: #171512;
  border-color: #171512;
  color: #fffdf8;
}

.headerToggle[data-primary="true"]:hover {
  background: #38342d;
}

.headerToggle:focus-visible,
.headerSelect:focus-visible,
.labNav a:focus-visible {
  outline: 2px solid #9b4827;
  outline-offset: 2px;
}

.storageNotice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 8px 12px;
  border: 1px solid #b42318;
  background: #fff4f2;
  color: #8f1c13;
  font-size: 12px;
  line-height: 1.5;
}

.storageNotice > span {
  flex: 1 1 280px;
}

.errorBox {
  margin-top: 12px;
  border: 1px solid #b42318;
  background: #fff4f2;
  color: #b42318;
  padding: 10px 12px;
  font-family: var(--font-jetbrains), monospace;
  font-size: 12px;
  line-height: 1.5;
  /* A runtime error carries the failing source line on its own line below the
     message; without this the newline collapses and the two run together. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.actionRow {
  margin-top: 12px;
}

.actionRow button,
.editorHeader button {
  min-height: 38px;
  border: 1px solid rgba(23, 21, 18, 0.22);
  background: #ffffff;
  color: #171512;
  padding: 0 12px;
  font: inherit;
  font-family: var(--font-jetbrains), monospace;
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
}

.actionRow button:hover,
.editorHeader button:hover {
  border-color: #171512;
}

.darkButton,
.editorHeader button {
  background: #171512 !important;
  color: #f7f3ea !important;
  border-color: #171512 !important;
}

.editorHeader .guideButton {
  background: #e8dcc2 !important;
  color: #171512 !important;
  border-color: #171512 !important;
}

.editorHeader .guideButton:hover {
  background: #d9c8a4 !important;
}

.editorHeader .pasteButton {
  display: none;
  background: #e8552e !important;
  color: #ffffff !important;
  border-color: #e8552e !important;
  font-weight: 600;
}

.editorHeader .pasteButton:hover {
  background: #d44722 !important;
  border-color: #d44722 !important;
}

.editorHeader .clearButton {
  display: none;
  background: #ffffff !important;
  color: #171512 !important;
  border: 1px solid rgba(23, 21, 18, 0.3) !important;
}

.editorHeader .clearButton:hover {
  background: #f0eae1 !important;
  border-color: #171512 !important;
}

.editorHeader {
  flex: 0 0 auto;
  min-height: 64px;
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(23, 21, 18, 0.18);
}

.editorHeader span {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.emptyState {
  margin: 0;
  padding: 18px 14px;
}

.editorHeader button:disabled {
  opacity: 0.5;
  cursor: default;
}

.viewToggle {
  display: flex;
  gap: 0;
}

.editorHeader .viewToggle button {
  min-height: 32px;
  border: 1px solid #171512 !important;
  background: #ffffff !important;
  color: #171512 !important;
  padding: 0 14px;
  font-family: var(--font-jetbrains), monospace;
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
}

.editorHeader .viewToggle button + button {
  border-left: none !important;
}

.editorHeader .viewToggle button[data-active="true"] {
  background: #171512 !important;
  color: #f7f3ea !important;
}

.editorHeader .keyButton {
  background: transparent !important;
  color: rgba(23, 21, 18, 0.62) !important;
  border-color: rgba(23, 21, 18, 0.22) !important;
  padding: 0 10px;
  font-size: var(--pf-fs-mono);
}

.editorHeader .keyButton:hover {
  color: #171512 !important;
  border-color: #171512 !important;
}

.editorHeader .genField {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(23, 21, 18, 0.62);
  font-family: var(--font-jetbrains), monospace;
  font-size: var(--pf-fs-mono);
  text-transform: uppercase;
}

.editorHeader .genField input {
  width: 56px;
  min-height: 38px;
  border: 1px solid rgba(23, 21, 18, 0.3);
  background: #ffffff;
  color: #171512;
  padding: 0 8px;
  font-family: var(--font-jetbrains), monospace;
  font-size: 12px;
}

.editorHeader .genThinking {
  min-height: 38px;
  border: 1px solid rgba(23, 21, 18, 0.3);
  background: #ffffff;
  color: #171512;
  padding: 0 8px;
  font-family: var(--font-jetbrains), monospace;
  font-size: 12px;
  text-transform: uppercase;
  cursor: pointer;
}

@keyframes jobPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.variantActions {
  display: flex;
  gap: 8px;
}

.variantActions button {
  flex: 1;
  min-height: 34px;
  border-radius: 4px;
  border: 1px solid rgba(23, 21, 18, 0.22);
  background: #ffffff;
  color: #171512;
  font: inherit;
  font-family: var(--font-inter), system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  cursor: pointer;
}

.variantActions button:hover {
  border-color: #171512;
}

.modalOverlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(23, 21, 18, 0.55);
}

.modalCard {
  border-radius: 8px;
  box-shadow: 0 20px 64px rgba(23, 21, 18, 0.25);
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid #171512;
  background: #fffdf8;
  color: #171512;
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(23, 21, 18, 0.18);
}

.modalHeader span {
  font-size: 14px;
  font-weight: 700;
}

.modalHeader button {
  border-radius: 4px;
  min-width: 30px;
  min-height: 30px;
  border: 1px solid rgba(23, 21, 18, 0.22);
  background: #ffffff;
  color: #171512;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.modalHeader button:hover {
  border-color: #171512;
}

.modalBody {
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
}

.modalBody p {
  margin: 0 0 12px;
}

.modalBody h4 {
  margin: 20px 0 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(23, 21, 18, 0.14);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modalBody ul {
  margin: 0 0 12px;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.modalBody code {
  font-family: var(--font-jetbrains), monospace;
  font-size: 12px;
  background: rgba(23, 21, 18, 0.07);
  padding: 1px 4px;
}

.modalBody pre {
  margin: 0 0 12px;
  padding: 12px;
  overflow-x: auto;
  border: 1px solid rgba(23, 21, 18, 0.18);
  background: #171512;
  color: #f7f3ea;
  font-family: var(--font-jetbrains), monospace;
  font-size: 12px;
  line-height: 1.5;
}

.modalNote {
  color: rgba(23, 21, 18, 0.62);
  font-size: 12px;
}

@media (max-width: 980px) {
  .header,
    .previewHeader,
    .editorHeader {
      align-items: flex-start;
      flex-direction: column;
    }

  .previewHeader {
      gap: 10px;
      margin-bottom: 12px;
    }

  .editorHeader button {
      min-height: 36px;
      padding: 0 10px;
      font-size: 11px;
    }

  .editorHeader .pasteButton,
    .editorHeader .clearButton {
      display: inline-flex;
    }

  .stats {
      justify-content: flex-start;
      text-align: left;
    }

  /* Action buttons become full-width rows — easy to hit, nothing truncated. */
  .actionRow {
      display: grid;
      grid-template-columns: 1fr;
      gap: 8px;
    }

  .actionRow button {
      width: 100%;
      min-height: 44px;
    }

}

/* ── Community fork badge ── */
.forkBadge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: #925035;
  font-size: 11px;
}

.forkBadge > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.forkBadge button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  flex: none;
}

.variantActions button:disabled {
  opacity: 0.4;
  cursor: default;
}

.variantActions button:focus-visible,
.modalHeader button:focus-visible {
  outline: 2px solid #9b4827;
  outline-offset: 2px;
}
