.pg {
  --pg-border: #ddd;
  --pg-accent: #191919;
  --pg-chrome: #f3f3f3;
  margin: 36px 0 48px;
  color: #171717;
}

.pg button.pg-close-diagram,
.pg-pane-switch,
.pg button.pg-expand,
.pg-touch-hint,
.pg-inspector,
.pg-diagram-status,
.pg button.pg-show-update { display: none; }

.pg button,
.pg select,
.pg textarea { font: inherit; }

.pg button {
  padding: 6px 9px;
  border: 1px solid var(--pg-border);
  border-radius: 6px;
  background: white;
  color: #222;
  font-size: 12px;
  cursor: pointer;
}

.pg button:disabled { opacity: .45; cursor: default; }
.pg button:hover:not(:disabled) { border-color: #666; }
.pg :is(button, input, select, summary, textarea):focus-visible { outline: 2px solid #111; outline-offset: 3px; }

.pg-workspace {
  display: flex;
  flex-direction: column;
  height: max(320px, calc(100svh - var(--masthead-height, 0px) - 32px));
  overflow: hidden;
  border: 1px solid var(--pg-border);
  border-radius: 12px;
  background: white;
  box-shadow: 0 8px 24px rgb(0 0 0 / 6%);
}

.pg-workspace-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  min-height: 30px;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--pg-border);
  background: #ededed;
}

.pg-window-title {
  margin: 0;
  color: #333;
  font-size: 12px;
  font-weight: 600;
}
.pg-window-lights {
  display: flex;
  gap: 7px;
  padding-left: 2px;
}

.pg .pg-window-link {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 5px;
  min-width: 0;
  min-height: 36px;
  color: #202124;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  text-align: right;
  text-wrap: balance;
}

@media (max-width: 360px) {
  .pg-window-link > span { display: none; }
}

.pg-window-lights > span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 10%);
}

.pg-window-lights > span:nth-child(1) { background: #ff5f57; }
.pg-window-lights > span:nth-child(2) { background: #febc2e; }
.pg-window-lights > span:nth-child(3) { background: #28c840; }

.pg-panes {
  display: grid;
  flex: 1;
  grid-template-columns: clamp(280px, 32%, 460px) minmax(0, 1fr);
  min-height: 0;
}

.pg-chat,
.pg-viewer {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.pg-chat { border-right: 1px solid var(--pg-border); }

.pg-pane-title {
  margin: 0;
  color: #333;
  font-size: 12px;
  font-weight: 600;
}

.pg-chat-header {
  min-height: 44px;
  border-bottom: 1px solid var(--pg-border);
  background: var(--pg-chrome);
}

.pg-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 14px;
}

.pg button.pg-reset {
  padding: 0 2px;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: #303238;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
}


.pg-tab-strip {
  display: flex;
  align-items: end;
  min-height: 44px;
  padding: 5px 10px 0;
  border-bottom: 1px solid var(--pg-border);
  background: #ededed;
}

.pg-preview-tab {
  margin-bottom: -1px;
  padding: 8px 20px;
  border: 1px solid var(--pg-border);
  border-bottom-color: white;
  border-radius: 8px 8px 0 0;
  background: white;
}

.pg-browser-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--pg-border);
  background: var(--pg-chrome);
}

.pg-browser-bar button {
  width: 28px;
  height: 27px;
  padding: 0;
  border-color: transparent;
  font-size: 16px;
}

.pg-browser-bar button.pg-share {
  width: auto;
  margin-inline-start: auto;
  padding-inline: 8px;
  font-size: 12px;
  font-weight: 600;
}

.pg-address {
  flex: 1;
  min-width: 0;
  margin-left: 4px;
  padding: 5px 12px;
  border: 1px solid var(--pg-border);
  border-radius: 999px;
  background: white;
  color: #444;
  font: inherit;
  font-size: 12px;
  text-overflow: ellipsis;
}

.pg-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 0;
}

.pg-messages p {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.pg-messages .pg-user {
  margin-left: 20px;
  padding: 9px 11px;
  border-radius: 8px;
  background: #f0f0f2;
}

.pg-messages .pg-error { color: #9b2424; }
.pg-messages .pg-activity {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #56565d;
}

.pg-activity::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  animation: pg-thinking 1.25s ease-in-out infinite alternate;
}

@keyframes pg-thinking {
  from { opacity: .35; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .pg-activity::before { animation: none; }
}

.pg-edit-details { margin: -8px 0 16px; color: #555; font-size: 12px; }
.pg button.pg-retry { display: block; margin: -8px 0 12px; }
.pg-edit-details > summary { width: fit-content; text-decoration: underline; text-underline-offset: 2px; }
.pg-messages .pg-edit-details > p { margin: 6px 0 0; font-size: inherit; }
.pg-chat-footer { padding: 10px 12px; }

.pg-composer {
  padding: 7px;
  border: 1px solid #ccc;
  border-radius: 9px;
  background: white;
}

.pg-composer:focus-within { border-color: #777; }

.pg textarea {
  display: block;
  width: 100%;
  min-height: 56px;
  max-height: 124px;
  padding: 5px;
  resize: vertical;
  border: 0;
  background: white;
  color: #111;
  font-size: 13px;
  line-height: 1.5;
}
.pg textarea::placeholder { color: #626267; }

.pg textarea:focus-visible { outline-offset: -1px; }

.pg-send-row,
.pg-toolbar,
.pg-focus:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 6px 12px;
  color: #444;
  background: white;
  border-bottom: 1px solid var(--pg-border);
  font-size: 12px;
}
.pg-focus button {
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: #333;
  text-decoration: underline;
}
.pg-save-dialog {
  max-width: min(360px, 90vw);
  padding: 20px;
  border: 1px solid #ccc;
  border-radius: 10px;
  color: #222;
}
.pg-save-dialog form { display: grid; gap: 8px; }
.pg-save-dialog h3, .pg-save-dialog p { margin: 0; }
.pg-save-dialog input { padding: 6px; }
.pg-save-dialog form > div { display: flex; justify-content: end; gap: 8px; }
.pg-share-dialog .pg-share-actions { display: grid; grid-template-columns: 1fr 1fr; margin-block: 6px; }
.pg-share-dialog p { font-size: 13px; }
.pg-share-dialog [data-pg-share-title] { font-weight: 600; }
.pg-key-dialog ul { display: grid; gap: 8px; margin: 5px 0; padding: 0; font-size: 13px; list-style: none; }
.pg-key-dialog li { display: flex; align-items: center; gap: 8px; }
.pg-key-swatch { width: 16px; height: 12px; flex: 0 0 auto; border: 2px solid; border-radius: 2px; }
.pg-download-workspace { display: inline-block; margin: 0 0 8px; text-decoration: underline; }

.pg-tools { display: flex; align-items: center; }

.pg-send-row { justify-content: space-between; gap: 10px; margin-top: 5px; }
.pg-composer-meta { display: flex; flex-wrap: wrap; gap: 2px 10px; padding-inline-start: 5px; }
.pg-send-row .pg-model { margin: 0; color: #555; font-size: 11px; font-weight: 600; }
.pg-send-row button { margin-left: auto; border-color: var(--pg-accent); background: var(--pg-accent); color: white; white-space: nowrap; }

.pg-chat-status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  min-height: 18px;
  margin-top: 7px;
  color: #555;
  font-size: 11px;
  line-height: 1.45;
}
.pg-chat-status p { margin: 0; }


.pg-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  min-height: 44px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--pg-border);
  background: var(--pg-chrome);
}

.pg-toolbar.pg-canvas-controls {
  border-bottom: 0;
  background: transparent;
}

.pg-toolbar select {
  min-width: 0;
  max-width: 100%;
  padding: 4px 10px;
  border: 1px solid var(--pg-border);
  border-radius: 6px;
  background: white;
  color: #222;
  font-size: 12px;
  text-overflow: ellipsis;
}

.pg-tools { gap: 4px; }
.pg-tools button { padding: 4px 7px; }
.pg-tools button[aria-pressed=true] { border-color: #666; background: #eee; }

.pg-zoom {
  display: grid;
  grid-template-columns: 30px minmax(46px, auto) 30px;
  align-items: center;
  border: 1px solid var(--pg-border);
  border-radius: 8px;
  background: white;
  text-align: center;
}
.pg-zoom button {
  width: 100%;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 17px;
}
.pg-zoom button:hover:not(:disabled) { background: #f4f4f4; }
.pg-zoom button[data-pg-zoom="fit"] { font-size: 13px; font-variant-numeric: tabular-nums; }

.pg-options { position: relative; }
.pg-options > summary {
  padding: 3px 7px;
  border: 1px solid var(--pg-border);
  border-radius: 6px;
  font-size: 13px;
  list-style: none;
}
.pg-options > summary::-webkit-details-marker { display: none; }
.pg .pg-options > summary::after { content: none; }
.pg-options-panel {
  position: absolute;
  z-index: 2;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  gap: 4px;
  min-width: 130px;
  padding: 5px;
  border: 1px solid var(--pg-border);
  border-radius: 8px;
  background: white;
  box-shadow: 0 4px 16px rgb(0 0 0 / 12%);
}
.pg-options-panel button { text-align: left; }

.pg-canvas {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.pg-canvas .pg-empty { display: grid; min-height: 100%; place-items: center; margin: 0; padding: 16px; color: #666; font-size: 13px; text-align: center; }
.pg-canvas > svg { display: block; width: 100%; height: 100%; }
.pg-canvas .joint-paper { background: white; }
.pg-options-panel p { margin: 3px 6px; max-width: 22ch; color: #666; font-size: 11px; line-height: 1.5; }
.pg-options-panel .pg-touch-hint { display: none; }
.pg a { color: inherit; text-underline-offset: 3px; }

@media (max-width: 760px), (max-width: 1000px) and (max-height: 500px) and (pointer: coarse) {
  .pg-tab-strip,
  .pg-address,
  .pg-view-hint { display: none; }
  .pg-options-panel .pg-touch-hint { display: block; }
  .pg-panes { grid-template-columns: minmax(0, 1fr); }
  .pg-pane-switch {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-bottom: 1px solid var(--pg-border);
    background: var(--pg-chrome);
  }
  .pg-pane-switch button {
    flex: 1;
    min-height: 44px;
    border-color: transparent;
    background: transparent;
    font-size: 14px;
  }
  .pg-pane-switch button[aria-pressed="true"] {
    border-color: var(--pg-border);
    background: white;
    font-weight: 600;
  }
  .pg-chat,
  .pg-panes > .pg-viewer { grid-area: 1 / 1; }
  .pg[data-pg-pane="chat"] .pg-panes > .pg-viewer,
  .pg[data-pg-pane="preview"] .pg-chat { visibility: hidden; }
  .pg-chat { border-right: 0; }
  .pg-messages p { font-size: 14px; }
  .pg textarea { min-height: 82px; font-size: 16px; resize: none; }
  .pg button.pg-show-update {
    display: block;
    width: min(164px, 100%);
    margin: 0 0 12px;
  }
  .pg-show-update img {
    display: block;
    width: 100%;
    height: 96px;
    object-fit: contain;
  }
  .pg-diagram-dialog[open] {
    position: fixed;
    inset: 0;
    display: flex;
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: white;
  }
  body:has(.pg-diagram-dialog[open]) { overflow: hidden; }
  .pg-diagram-dialog > .pg-viewer { flex: 1; }
  .pg-canvas { touch-action: none; overscroll-behavior: contain; }
  .pg-toolbar { flex-wrap: nowrap; }
  .pg-toolbar select { min-width: 0; }
  .pg-tools { flex-shrink: 0; }
  .pg-browser-bar { min-height: 34px; padding-block: 2px; }
  .pg-browser-bar button { width: 40px; }
  .pg-diagram-dialog button.pg-close-diagram {
    display: block;
    width: 44px;
    height: 44px;
    margin-left: auto;
    order: 1;
    font-size: 20px;
  }
  .pg-panes button.pg-expand { display: block; width: auto; height: 32px; margin-left: auto; padding: 0 8px; font-size: 12px; }
  .pg-inspector:not([hidden]) {
    display: block;
    padding: 8px 12px;
    border-top: 1px solid var(--pg-border);
    background: white;
    font-size: 13px;
  }
  .pg-inspector > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .pg-inspector p { margin: 2px 0 6px; }
  .pg-inspected-name { font-weight: 600; }
  .pg-diagram-status:not([hidden]) {
    display: block;
    margin: 0;
    padding: 6px 12px;
    font-size: 12px;
  }
}

.c4-introduction { scroll-margin-top: 24px; }

@media (max-width: 500px) {
  .pg-toolbar { flex-wrap: wrap; }
  .pg-toolbar select { flex: 1 1 100%; }
  .pg-tools { margin-inline-start: auto; }
}
.product-intro { max-width: 65ch; margin-top: 16px; color: #555; font-size: 17px; line-height: 1.6; }

.pg-preview-panel:not([hidden]) {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
.pg-viewer button.pg-preview-tab {
  padding: 8px 14px;
  border-color: transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
}
.pg-viewer button.pg-preview-tab[aria-pressed="true"] {
  border-color: var(--pg-border);
  border-bottom-color: white;
  background: white;
  font-weight: 600;
}
#pg-live-model > .pg-empty { margin: auto; padding: 16px; color: #555; }
.pg-model-source {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 16px;
  overflow: auto;
  color: #24292f;
  font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.pg-model-source .dsl-keyword { color: #6f329c; font-weight: 600; }
.pg-model-source .dsl-string { color: #246334; }
.pg-model-source .dsl-comment { color: #57606a; }
.pg-model-source .dsl-operator { color: #095cb6; }
@media (max-width: 760px), (max-width: 1000px) and (max-height: 500px) and (pointer: coarse) {
  [data-c4-playground] .pg-tab-strip { display: flex; }
}

.pg-canvas [data-c4-dimmed] { opacity: .27; }
