/* Chart Maker (chart-maker.html): controls beside a live preview of the
   picture; stacked on phones */
.cm { max-width: 1280px; margin: 0 auto; padding: 32px 24px 64px; }
.cm-head h1 { margin: 0 0 8px; font-size: 34px; letter-spacing: -0.02em; color: var(--ink); }
.cm-head p { margin: 0 0 28px; max-width: 640px; font-size: 16px; line-height: 1.6; color: var(--muted); }

.cm-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 28px; align-items: start; }
.cm-controls { display: flex; flex-direction: column; gap: 18px; padding: 20px; border: 1px solid var(--card-border); border-radius: 16px; background: var(--bg) var(--grain); }
.cm-field { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.cm-label { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); padding: 0; }
.cm-label-sm { text-transform: none; letter-spacing: 0; font-weight: 500; }
.cm-field select, .cm-field textarea {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card);
  font: 500 15px var(--sans); color: var(--ink);
}
.cm-field textarea { resize: vertical; line-height: 1.4; }
.cm-seg { display: flex; flex-wrap: wrap; }
.cm-seg .seg-btn { flex: 1; white-space: nowrap; }
/* Data first: numbered steps, the picks as chips */
.cm-step { display: flex; align-items: center; gap: 8px; }
.cm-step-n {
  width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; font: 700 11px var(--sans); letter-spacing: 0;
}
.cm-data { display: flex; flex-direction: column; gap: 8px; }
.cm-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-pick {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 5px 4px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--card); font: 500 13px var(--sans); color: var(--ink); overflow-wrap: anywhere;
}
.cm-pick:not(:has(button)) { padding-right: 10px; }
.cm-pick.pay { border-color: #9BB5CB; background: #EEF3F7; }
.cm-pick button {
  flex: none; width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--surface); color: var(--muted);
  font: 500 14px/1 var(--sans); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.cm-pick button:hover { background: var(--border); color: var(--ink); }
.cm-pick button:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.cm-data > select {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card);
  font: 500 15px var(--sans); color: var(--ink);
}
/* The kinds of chart: a button showing the chart you're on, opening a menu
   like the site menu (two columns on wide screens, over the preview) */
.cp { position: relative; }
.cp-btn {
  width: 100%; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--ink);
  font: inherit; text-align: left; cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cp-btn:hover, .cp-btn[aria-expanded="true"] { border-color: var(--ink-2); box-shadow: 0 6px 10px -8px rgba(27, 26, 23, 0.35); }
.cp-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.cp-btn .nav-chevron { color: var(--muted); }
.cp-btn[aria-expanded="true"] .nav-chevron { transform: rotate(180deg); }
.cp-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--surface); display: flex; align-items: center; justify-content: center; color: var(--ink-2); }
.cp-label { min-width: 0; }
.cp-group { display: block; margin-bottom: 1px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.cp-name { display: block; font-size: 15px; font-weight: 600; }
.cp-about { display: block; margin-top: 1px; font-size: 12.5px; line-height: 1.35; color: var(--muted); }
.cp-menu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 30; width: 100%; max-height: min(70vh, 560px); overflow-y: auto; padding: 6px 8px 8px;
  border-radius: 14px; background: var(--card); color: var(--ink);
  box-shadow: 0 2px 4px rgba(27, 26, 23, 0.08), 0 12px 32px rgba(27, 26, 23, 0.18);
}
.cp-menu[hidden] { display: none; }
.cp-menu::-webkit-scrollbar { width: 8px; }
.cp-menu::-webkit-scrollbar-button { display: none; height: 0; }
.cp-menu::-webkit-scrollbar-track { background: transparent; margin: 12px 0; }
.cp-menu::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 8px; background: var(--border) padding-box; }
.cp-menu::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
@supports not selector(::-webkit-scrollbar) { .cp-menu { scrollbar-width: thin; scrollbar-color: var(--border) transparent; } }
.cp-sub { margin: 12px 4px 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.cp-col > .cp-sub:first-child { margin-top: 6px; }
.cp-item {
  width: 100%; display: grid; grid-template-columns: 28px 1fr 16px; align-items: center; gap: 10px; padding: 7px 8px;
  border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.cp-item:hover, .cp-item:focus-visible { background: var(--surface); outline: none; }
.cp-item:focus-visible { box-shadow: inset 0 0 0 2px var(--ink); }
.cp-item:disabled { opacity: 0.45; cursor: not-allowed; }
.cp-item .cp-icon { width: 28px; height: 28px; border-radius: 7px; }
.cp-item .cp-name { font-size: 14px; font-weight: 500; }
.cp-item[aria-checked="true"] .cp-name { font-weight: 700; }
.cp-item[aria-checked="true"] .cp-icon { background: var(--ink); color: #fff; }
.cp-check { color: var(--color-2); visibility: hidden; }
.cp-item[aria-checked="true"] .cp-check { visibility: visible; }
@media (min-width: 901px) {
  .cp-menu { width: 660px; max-height: none; overflow: visible; display: grid; grid-template-columns: 1fr 1fr; padding: 0; }
  .cp-col { padding: 8px 10px 10px; }
  .cp-col + .cp-col { border-left: 1px solid var(--line); }
  .cp-menu.cp-one { width: 380px; display: block; }
}
.cm-suggest { display: flex; flex-direction: column; gap: 6px; }
.cm-suggest button {
  text-align: left; padding: 8px 10px; border: 1px dashed var(--border); border-radius: 8px; background: transparent;
  font: 400 13px/1.4 var(--sans); color: var(--ink-2); cursor: pointer;
}
.cm-suggest button:hover { border-color: var(--ink-2); color: var(--ink); }
.cm-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.cm-checks legend { grid-column: 1 / -1; margin-bottom: 8px; }
.cm-checks label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.cm-checks input { accent-color: var(--ink); width: 16px; height: 16px; }
.cm-download {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 0; border-radius: 10px;
  background: var(--ink); color: var(--bg); font: 500 15px var(--sans); cursor: pointer;
}
.cm-fine { margin: -8px 0 0; font-size: 12px; color: var(--muted); }

.cm-preview { position: sticky; top: 80px; }
/* As big as fits: the full width for a wide picture, the screen's height
   for a square or tall one */
.cm-preview canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 110px); border-radius: 10px; box-shadow: 0 1px 0 var(--card-border), 0 10px 30px rgba(40, 40, 30, 0.10); }

@media (max-width: 900px) {
  .cm { padding: 24px 16px 48px; }
  .cm-layout { grid-template-columns: minmax(0, 1fr); }
  .cm-preview { position: static; order: -1; }
}

/* Your own labels: month, words, remove */
.cm-notes { display: flex; flex-direction: column; gap: 8px; }
.cm-notes:empty { display: none; }
.cm-note { display: grid; grid-template-columns: 128px minmax(0, 1fr) 32px; gap: 6px; align-items: center; }
.cm-note input {
  width: 100%; min-width: 0; min-height: 38px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); font: 500 14px var(--sans); color: var(--ink);
}
.cm-note-remove { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; font-size: 18px; color: var(--muted); cursor: pointer; }
.cm-note-remove:hover { background: var(--surface); color: var(--down); }
.cm-add-note {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; min-height: 36px; padding: 0 12px;
  border: 1px dashed var(--border); border-radius: 8px; background: transparent; font: 500 14px var(--sans); color: var(--ink-2); cursor: pointer;
}
.cm-add-note:hover { border-color: var(--ink-2); color: var(--ink); }
.cm-hint { margin: 0; font-size: 13px; color: var(--muted); }
.cm-reset { padding: 0; border: 0; background: none; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.cm-copy {
  min-height: 40px; margin-top: -8px; border: 1px solid var(--border); border-radius: 10px; background: var(--card);
  font: 500 14px var(--sans); color: var(--ink-2); cursor: pointer;
}
.cm-copy:hover { border-color: var(--ink-2); color: var(--ink); }
.cm-status { margin: -10px 0 0; font-size: 13px; color: var(--up); overflow-wrap: anywhere; }
.cm-status:empty { display: none; }

/* Labels on the chart can be dragged */
.cm-preview canvas { touch-action: pan-y; }
.cm-preview canvas.over-label { cursor: grab; }
.cm-preview canvas.dragging { cursor: grabbing; touch-action: none; }
/* Square and tall pictures shouldn't fill a wide screen */
.cm-preview { max-width: 900px; }

/* Hidden controls stay hidden, whatever their display */
.cm [hidden] { display: none !important; }
.cm-group { display: flex; flex-direction: column; gap: 18px; }

/* What to chart: a list per line, with its color when comparing */
.cm-lines { display: flex; flex-direction: column; gap: 8px; }
.cm-line { display: flex; align-items: center; gap: 8px; }
.cm-line select {
  flex: 1; min-width: 0; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card);
  font: 500 15px var(--sans); color: var(--ink);
}
.cm-swatch { flex: none; width: 14px; height: 4px; border-radius: 2px; }

/* Custom dates and quick starting points */
.cm-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cm-dates label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.cm-dates input {
  width: 100%; min-width: 0; min-height: 38px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); font: 500 14px var(--sans); color: var(--ink);
}
.cm-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-quick:empty { display: none; }
.cm-chip {
  min-height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--card);
  font: 500 13px var(--sans); color: var(--ink-2); cursor: pointer;
}
.cm-chip:hover { border-color: var(--ink-2); color: var(--ink); }
.cm-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* Download beside Copy Picture */
.cm-actions { display: flex; gap: 8px; }
.cm-actions .cm-download { flex: 1; }
.cm-actions .cm-copy-img { flex: 1; margin-top: 0; min-height: 44px; }

/* Notes on the data, fair-chart checks, the embed code and the picture's description */
.cm-checks /* Fair-chart checks: a short list, each with its fix */
.cm-fair-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.cm-fair-list li { position: relative; padding: 8px 10px 8px 30px; border-radius: 8px; background: color-mix(in srgb, var(--color-2) 8%, var(--card)); font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.cm-fair-list li::before { content: "!"; position: absolute; left: 9px; top: 8px; width: 14px; height: 14px; border-radius: 50%; background: var(--color-2); color: #fff; font: 700 10px/14px var(--sans); text-align: center; }
.cm-fair-list li.ok { background: color-mix(in srgb, var(--up) 8%, var(--card)); }
.cm-fair-list li.ok::before { content: "✓"; background: var(--up); }
.cm-fair-list .cm-chip { margin-top: 4px; }
/* Notes on the data */
.cm-check-line { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.cm-check-line input { accent-color: var(--ink); width: 16px; height: 16px; }
.cm-auto-list { margin: 4px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.cm-auto-list li + li { margin-top: 3px; }
/* Embed code and the picture's description */
.cm-embed { display: flex; flex-direction: column; gap: 6px; }
.cm-embed textarea, .cm-alt textarea {
  width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); font: 12px/1.45 var(--mono); color: var(--ink-2); resize: vertical;
}
.cm-alt textarea { font: 13px/1.45 var(--sans); }
/* Embedded on another site: just the picture */
body.cm-embedded::before { display: none; }
body.cm-embedded > a { display: block; }

/* Choosing a chart: what each dot or bar is, the axes (a slot each), and
   the charts that fit as buttons, the rest folded under "more charts" */
.cm-slot { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px; align-items: start; }
.cm-slot-name { display: flex; align-items: center; gap: 6px; min-height: 40px; font-size: 13px; font-weight: 700; color: var(--ink); }
.cm-slot-name i {
  flex: none; width: 20px; height: 20px; border-radius: 5px; background: var(--ink); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; font: 700 11px var(--sans); font-style: normal;
}
.cm-slot-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cm-slot-body > select {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card);
  font: 500 15px var(--sans); color: var(--ink);
}
.cm-slot-body .cm-hint { margin: 0; }
.cm-swap { align-self: flex-start; margin-left: 82px; }
/* Menus like the site menu: the kind of data and the chart as a big
   button; every dropdown as a smaller one with the same white panel */
.cp-btn .cp-about { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs { position: relative; min-width: 0; }
.cs[hidden] { display: none; }
.cs-native { display: none !important; }
.cs > .cp-btn { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; min-height: 40px; padding: 8px 10px 8px 12px; border-radius: 8px; font: 500 15px var(--sans); }
.cs-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-menu.cs-menu { width: 100%; min-width: min(290px, calc(100vw - 48px)); max-height: min(60vh, 380px); overflow-y: auto; display: block; padding: 4px 6px 6px; }
.cs-menu .cp-col { padding: 0; }
.cs-menu .cp-col + .cp-col { border-left: 0; border-top: 1px solid var(--line); margin-top: 4px; }
.cs-menu .cp-sub { margin: 10px 4px 2px; }
.cs-menu .cp-col:first-child > .cp-sub:first-child { margin-top: 6px; }
.cp-item.cp-plain { grid-template-columns: minmax(0, 1fr) 16px; padding: 7px 10px; }
.cp-plain .cp-name { font-size: 14px; }
.cm-slot-body > .cs, .cm-field > .cs { width: 100%; }
.cm-slot-body .cs-menu { left: auto; right: 0; }
/* The menus open over the preview on wide screens */
@media (min-width: 901px) { #cm-mode .cp-menu:not(.cp-one) { width: 640px; } }
/* Checklist buttons (Up, Each One, A Line Each): how many, then which */
.cs-two { display: flex; flex-direction: column; min-width: 0; text-align: left; }
.cs-count { font-size: 15px; font-weight: 600; }
.cs-list { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.cm-multi > .cp-btn { padding-top: 7px; padding-bottom: 7px; }
.cp-item.cp-multi { grid-template-columns: 18px minmax(0, 1fr); padding: 6px 10px; }
.cp-box { width: 16px; height: 16px; border: 1.5px solid var(--border); border-radius: 4px; background: var(--card); position: relative; }
.cp-multi[aria-checked="true"] .cp-box { background: var(--ink); border-color: var(--ink); }
.cp-multi[aria-checked="true"] .cp-box::after { content: ""; position: absolute; left: 4.5px; top: 1px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.cp-multi[aria-checked="true"] .cp-name { font-weight: 600; }
.cs-menu .cp-sub { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cp-sub-act { border: 0; background: none; padding: 2px 4px; border-radius: 6px; font: 600 12px var(--sans); letter-spacing: 0; text-transform: none; color: var(--slate, var(--ink-2)); cursor: pointer; }
.cp-sub-act:hover, .cp-sub-act:focus-visible { background: var(--surface); text-decoration: underline; outline: none; }
.cp-item.cp-act { grid-template-columns: minmax(0, 1fr); }
.cp-act .cp-name { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.cs-menu .cp-col:last-child:has(.cp-act) { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 4px; }
.cm-plain { display: flex; align-items: center; min-height: 40px; padding: 0 2px; font: 500 15px var(--sans); color: var(--ink); }
.cm-across { flex-wrap: wrap; }
.cm-across .seg-btn { flex: 1 1 auto; white-space: normal; line-height: 1.25; }
