.mgpsg,
.mgpsg * {
  box-sizing: border-box;
}

.mgpsg {
  --mgpsg-bg: #f7f6f1;
  --mgpsg-surface: #ffffff;
  --mgpsg-panel: #f1f0ea;
  --mgpsg-ink: #111113;
  --mgpsg-muted: #67676d;
  --mgpsg-line: rgba(17, 17, 19, 0.1);
  --mgpsg-line-strong: rgba(17, 17, 19, 0.2);
  --mgpsg-red: #d64b3c;
  --mgpsg-blue: #2f69c7;
  --mgpsg-green: #258a56;
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--mgpsg-ink);
  font-family: "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mgpsg a {
  color: inherit;
}

.mgpsg__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mgpsg__header {
  display: grid;
  gap: 10px;
  max-width: 680px;
  margin: 0 0 22px;
}

.mgpsg__kicker,
.mgpsg__field span,
.mgpsg__select span,
.mgpsg__output-head label,
.mgpsg__status {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0;
}

.mgpsg__kicker {
  margin: 0;
  color: var(--mgpsg-muted);
  font-size: 12px;
  text-transform: uppercase;
}

.mgpsg__header h2 {
  margin: 0;
  color: var(--mgpsg-ink);
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.04;
  letter-spacing: 0;
}

.mgpsg__header p:last-child {
  max-width: 58ch;
  margin: 0;
  color: var(--mgpsg-muted);
  font-size: 16px;
  line-height: 1.55;
}

.mgpsg__layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(320px, 1.08fr);
  gap: 10px;
  align-items: stretch;
}

.mgpsg__panel {
  border: 1px solid var(--mgpsg-line);
  border-radius: 8px;
  background: var(--mgpsg-surface);
  box-shadow: 0 1px 2px rgba(17, 17, 19, 0.035);
}

.mgpsg__form {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.mgpsg__field,
.mgpsg__select {
  display: grid;
  gap: 8px;
}

.mgpsg__field span,
.mgpsg__select span,
.mgpsg__output-head label {
  color: var(--mgpsg-muted);
  font-size: 12px;
  text-transform: uppercase;
}

.mgpsg__field input,
.mgpsg__select select,
.mgpsg__output textarea {
  width: 100%;
  border: 1px solid var(--mgpsg-line);
  border-radius: 6px;
  background: #fbfbfa;
  color: var(--mgpsg-ink);
  font: inherit;
}

.mgpsg__field input {
  min-height: 48px;
  padding: 0 15px;
  font-size: 16px;
}

.mgpsg__field input:focus,
.mgpsg__select select:focus,
.mgpsg__output textarea:focus {
  outline: 2px solid color-mix(in oklab, var(--mgpsg-blue) 54%, transparent);
  outline-offset: 2px;
}

.mgpsg__controls {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 150px;
  gap: 10px;
  align-items: start;
}

.mgpsg__segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.mgpsg__segment label {
  min-width: 0;
  margin: 0;
}

.mgpsg__segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mgpsg__segment span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border: 1px solid var(--mgpsg-line);
  border-radius: 6px;
  background: #fbfbfa;
  color: var(--mgpsg-ink);
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.mgpsg__segment input:checked + span {
  background: var(--mgpsg-ink);
  color: var(--mgpsg-bg);
  border-color: var(--mgpsg-ink);
}

.mgpsg__segment input:focus-visible + span {
  outline: 2px solid color-mix(in oklab, var(--mgpsg-blue) 54%, transparent);
  outline-offset: 2px;
}

.mgpsg__select select {
  min-height: 48px;
  padding: 0 12px;
  appearance: auto;
}

.mgpsg__check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 0;
  color: var(--mgpsg-muted);
  font-size: 14px;
}

.mgpsg__check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--mgpsg-green);
}

.mgpsg__check code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

.mgpsg__hint {
  margin: -8px 0 0;
  color: var(--mgpsg-muted);
  font-size: 13px;
  line-height: 1.45;
}

.mgpsg__hint strong {
  color: var(--mgpsg-ink);
  font-weight: 650;
}

.mgpsg__hint code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--mgpsg-panel);
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.mgpsg__preview-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 28px;
  background: #efeee8;
}

.mgpsg__preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 148px;
}

.mgpsg__preview a {
  display: inline-flex;
  max-width: 100%;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.mgpsg__preview a:hover {
  transform: translateY(-2px);
  filter: drop-shadow(0 10px 16px rgba(17, 17, 19, 0.12));
}

.mgpsg__preview img {
  display: block;
  width: var(--mgpsg-badge-width, 338px);
  max-width: 100%;
  height: auto;
}

.mgpsg__output {
  grid-column: 1 / -1;
  padding: 16px;
}

.mgpsg__output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.mgpsg__actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mgpsg__icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--mgpsg-line);
  border-radius: 6px;
  background: #fbfbfa;
  color: var(--mgpsg-ink);
  cursor: pointer;
  text-decoration: none;
}

.mgpsg__icon-button:hover {
  background: var(--mgpsg-ink);
  border-color: var(--mgpsg-ink);
  color: var(--mgpsg-bg);
}

.mgpsg__icon-button svg {
  width: 18px;
  height: 18px;
}

.mgpsg__output textarea {
  min-height: 132px;
  resize: vertical;
  padding: 14px;
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.mgpsg--compact .mgpsg__layout {
  margin-top: 0;
}

.mgpsg__status {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--mgpsg-green);
  font-size: 12px;
}

@media (max-width: 860px) {
  .mgpsg__layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .mgpsg {
    padding: 0;
  }

  .mgpsg__controls {
    grid-template-columns: 1fr;
  }

  .mgpsg__output-head {
    align-items: flex-start;
  }
}
