.cg-editor {
  --cg-ink: #182421;
  --cg-muted: #52625B;
  --cg-line: #CFDAD3;
  --cg-panel: #ffffff;
  --cg-bg: #F7F8F4;
  --cg-brand: #006B53;
  --cg-brand-hover: #005441;
  --cg-soft: #DFF3E8;
  color: var(--cg-ink);
  background: var(--cg-panel);
  border: 1px solid var(--cg-line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(24, 36, 33, 0.06);
  padding: 16px;
}

.cg-layout {
  display: grid;
  grid-template-columns: minmax(0, 34fr) minmax(0, 66fr);
  gap: 16px;
  align-items: start;
}

.cg-col {
  min-width: 0;
}

.cg-col-chart {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "types custom export" "chart chart chart" "mapping mapping mapping";
  align-items: start;
  gap: 10px 12px;
  border-left: 1px solid var(--cg-line);
  padding-left: 16px;
}

.cg-editor [hidden] { display: none; }
.cg-empty-preview {
  min-height: 320px;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 20px;
  color: var(--cg-muted);
  text-align: center;
}

.cg-data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

.cg-label {
  display: block;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--cg-muted);
  margin-bottom: 6px;
}

.cg-paste {
  width: 100%;
  min-height: 160px;
  max-height: 320px;
  resize: vertical;
  overflow-y: auto;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  padding: 10px 12px;
  font: 14px/1.45 "IBM Plex Mono", ui-monospace, monospace;
  background: #fff;
  color: var(--cg-ink);
}

.cg-paste:focus {
  outline: 2px solid var(--cg-brand);
  outline-offset: 2px;
}

.cg-col-data.is-dragover {
  outline: 2px dashed var(--cg-brand);
  background: var(--cg-soft);
}

.cg-hint,
.cg-status,
.cg-export-note {
  font-size: 13px;
  color: var(--cg-muted);
  margin: 8px 0 0;
}

.cg-status[data-tone="error"],
.cg-export-note[data-tone="error"] {
  color: #A32424;
}

.cg-btn {
  appearance: none;
  border-radius: 8px;
  border: 1px solid transparent;
  min-height: 40px;
  padding: 0 14px;
  font: 600 14px/1 Instrument Sans, system-ui, sans-serif;
  cursor: pointer;
}

.cg-btn:disabled {
  background: #d7ddd9 !important;
  border-color: #d7ddd9 !important;
  color: #7a8b84 !important;
  cursor: not-allowed;
}

.cg-btn-primary {
  background: var(--cg-brand);
  color: #fff;
}

.cg-btn-primary:hover:not(:disabled) {
  background: var(--cg-brand-hover);
}

.cg-btn-secondary {
  background: #fff;
  border-color: var(--cg-line);
  color: var(--cg-ink);
}

.cg-btn-quiet {
  background: #fff;
  border-color: var(--cg-line);
  color: var(--cg-ink);
  font-weight: 500;
  min-height: 36px;
  padding: 0 10px;
}

.cg-check {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 14px;
}

.cg-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  font-size: 14px;
}

.cg-field input[type="text"],
.cg-field input[type="number"],
.cg-field select,
.cg-sheet {
  min-height: 36px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  padding: 6px 10px;
  font: 14px Instrument Sans, system-ui, sans-serif;
}

.cg-type-field { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.cg-type-field select {
  min-width: 0;
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: #fff;
  color: var(--cg-ink);
  font: inherit;
}
.cg-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.cg-data-actions label.cg-btn { display: inline-flex; align-items: center; justify-content: center; }
.cg-data-actions label:focus-within { outline: 2px solid var(--cg-brand); outline-offset: 2px; }

.cg-chart-toolbar {
  grid-area: types;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.cg-more-about {
  font-size: 13px;
  color: var(--cg-brand);
  text-decoration: none;
  white-space: nowrap;
}

.cg-more-about:hover {
  text-decoration: underline;
}

.cg-chart-stage {
  grid-area: chart;
  min-width: 0;
  position: relative;
  border: 1px solid var(--cg-line);
  border-radius: 12px;
  background: #fff;
}

.cg-chart-host {
  width: 100%;
  height: 360px;
}

.cg-sample-badge {
  position: absolute;
  z-index: 2;
  top: 10px;
  left: 10px;
  background: var(--cg-soft);
  color: var(--cg-brand);
  border-radius: 999px;
  font: 600 12px Instrument Sans, system-ui, sans-serif;
  padding: 4px 10px;
}

.cg-export-bar {
  grid-area: export;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.cg-export-settings > summary { list-style: none; }
.cg-export-settings > summary::-webkit-details-marker { display: none; }
.cg-export-settings > summary,
.cg-customize > summary {
  cursor: pointer;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  font-size: 14px;
}
.cg-export-menu {
  position: absolute;
  z-index: 3;
  right: 0;
  top: 48px;
  width: min(240px, 75vw);
  padding: 10px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 6px 18px #18242122;
}
.cg-export-menu button { margin-bottom: 6px; }
.cg-export-note { font-size: 13px; margin: 0; }
.cg-export-note:empty { display: none; }
.cg-mapping-summary { grid-area: mapping; margin: 0; color: var(--cg-muted); font-size: 13px; }
.cg-customize { grid-area: custom; position: relative; }
.cg-customize > summary { width: fit-content; }
.cg-customize-panel { padding-top: 10px; }
@media (min-width: 768px) and (max-width: 959px) {
  .cg-col-chart { grid-template-columns: minmax(0, 1fr); grid-template-areas: "types" "chart" "export" "mapping" "custom"; }
}

.cg-details {
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  padding: 0 10px;
  margin-bottom: 10px;
  background: #fff;
}

.cg-details > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 10px 0;
}

.cg-panel-body {
  padding-bottom: 10px;
}

.cg-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.cg-color-list {
  display: grid;
  gap: 8px;
}

.cg-color-item {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.cg-color-item input[type="color"] {
  width: 32px;
  height: 32px;
  border: 0;
  padding: 0;
  background: transparent;
}

.cg-noscript {
  color: var(--cg-muted);
}

@media (max-width: 767px) {
  .cg-layout { grid-template-columns: minmax(0, 1fr); }
  .cg-col-chart {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "types" "chart" "export" "mapping" "custom";
    padding-left: 0;
    border-left: 0;
  }
  .cg-paste { font-size: 16px; }
  .cg-editor { padding: 12px; }
  .cg-chart-host, .cg-empty-preview { height: 280px; min-height: 0; }
  .cg-btn { min-height: 44px; }
  .cg-export-bar { width: fit-content; }
}

@media (min-width: 960px) {
  .cg-editor .cg-label[for="cg-paste"] {
    display: flex;
    align-items: center;
    min-height: 44px;
    margin-bottom: 10px;
  }
  .cg-chart-toolbar { min-height: 44px; margin-bottom: 0; }
  .cg-export-settings > summary,
  .cg-customize > summary { line-height: 22px; }
}

.cg-example { height: 360px; padding: 12px 16px 8px; display: flex; flex-direction: column; }
.cg-example p { margin: 0; color: var(--cg-muted); font-size: 13px; }
[data-example-figure] { display: none; flex: 1; min-height: 0; }
[data-example-figure] svg { display: block; width: 100%; height: 100%; }
.cg-type-field select {
  appearance: none;
  padding-right: 32px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23182421' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 10px center / 16px 16px no-repeat;
}
.cg-export-settings > summary { font-size: 0; min-width: 44px; text-align: center; }
.cg-export-settings > summary::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg) translateY(-2px);
}
.cg-customize > summary { list-style: none; }
.cg-customize > summary::-webkit-details-marker { display: none; }
.cg-slider-icon { font-size: 16px; color: var(--cg-brand); }
.cg-mapping-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; }
.cg-mapping-summary button, .cg-settings-nav button {
  background: #fff;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  min-height: 44px;
  padding-inline: 9px;
  font: inherit;
  color: var(--cg-ink);
  cursor: pointer;
}
.cg-settings-nav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.cg-settings-nav button[aria-pressed="true"] { background: var(--cg-brand); color: #fff; }
.cg-settings-nav [data-settings-close] { margin-left: auto; }
.cg-customize-panel { min-width: 0; }
.cg-customize-panel details > summary { cursor: pointer; padding-block: 10px; }
@media (min-width: 1120px) {
  .cg-settings-open { grid-template-columns: minmax(235px, 29fr) minmax(0, 71fr); }
  .cg-settings-open .cg-col-chart {
    grid-template-columns: minmax(0, 1fr) auto minmax(238px, 270px);
    grid-template-areas: "types export custom" "chart chart custom" "mapping mapping custom";
  }
  .cg-settings-open .cg-customize > summary { font-weight: 600; }
  .cg-settings-open .cg-customize { border-left: 1px solid var(--cg-line); padding-left: 12px; }
}
@media (min-width: 960px) and (max-width: 1119px) {
  .cg-settings-open .cg-col-chart {
    grid-template-areas: "types custom export" "chart chart chart" "mapping mapping mapping" "panel panel panel";
  }
  .cg-settings-open .cg-customize { display: contents; }
  .cg-settings-open .cg-customize > summary { grid-area: custom; }
  .cg-settings-open .cg-customize-panel { grid-area: panel; }
}
@media (max-width: 767px) { .cg-example { height: 280px; padding: 10px; } }

.cg-btn-primary:not(:disabled) { background: var(--cg-brand); border-color: var(--cg-brand); color: #fff; }
.cg-btn-primary:not(:disabled):hover { background: var(--cg-brand-hover); }
@media (max-width: 767px) {
  .cg-layout { gap: 10px; }
  .cg-paste { height: 108px; min-height: 108px; }
  .cg-data-actions { margin-top: 4px; gap: 4px 8px; }
  .cg-chart-toolbar { margin-bottom: 0; }
  .cg-hint, .cg-status { margin-top: 4px; }
}

[data-example-figure] svg text { font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif !important; }
[data-sample-id="bar-region"] [data-example-figure="bar-region"],
[data-sample-id="dot-groups"] [data-example-figure="dot-groups"],
[data-sample-id="frequency-channel"] [data-example-figure="frequency-channel"],
[data-sample-id="histogram-minutes"] [data-example-figure="histogram-minutes"],
[data-sample-id="bar-sample"] [data-example-figure="bar-sample"],
[data-sample-id="line-orders"] [data-example-figure="line-orders"],
[data-sample-id="pie-channel"] [data-example-figure="pie-channel"],
[data-sample-id="scatter-pairs"] [data-example-figure="scatter-pairs"] { display: block; }
