:root {
  --blue: #165ea8;
  --blue-deep: #16365c;
  --blue-soft: #edf4fc;
  --orange: #f7931a;
  --orange-soft: #fff4e6;
  --orange-ink: #874200;
  --ink: #1b2d45;
  --muted: #596b82;
  --border: #dbe3ed;
  --surface: #f5f7fb;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  color: var(--ink);
  background: var(--surface);
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; }
header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 4%;
  border-top: 3px solid var(--orange);
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.brand {
  color: var(--blue-deep);
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -.8px;
  text-decoration: none;
}
.brand span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0;
}
#account { display: flex; gap: 16px; align-items: center; }
#account > span { overflow-wrap: anywhere; }
main { max-width: 1700px; margin: auto; padding: 32px 4%; }
h1 { font-size: 30px; letter-spacing: -1px; margin: 0; font-weight: 650; }
h2 { font-size: 24px; letter-spacing: -.5px; }
p { color: var(--muted); line-height: 1.65; }
.heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.workspace { display: grid; grid-template-columns: 180px minmax(340px, 430px) minmax(300px, 1fr); gap: 22px; }
aside h3 { font-size: 13px; margin-top: 0; }
#projects button {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  background: transparent;
  color: var(--blue);
  border: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
}
.editor { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 24px; }
.section-title { font-size: 14px; letter-spacing: 0; margin: 0 0 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.imports { display: flex; align-items: center; gap: 12px; }
small { font-size: 11px; color: var(--muted); line-height: 1.6; }
.google { display: flex; gap: 8px; margin: 18px 0; }
.google input { min-width: 0; }
.google button { white-space: nowrap; font-size: 11px; }
button, .file {
  border: 0;
  border-radius: 5px;
  background: var(--blue);
  color: #fff;
  padding: 12px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.secondary { color: var(--blue); background: var(--blue-soft); border: 1px solid var(--border); }
#login button[value=login], #archive-new, #empty-new, #to-customize, #to-publish, #publish {
  background: var(--orange);
  color: var(--blue-deep);
}
.danger { background: transparent; color: #a63e37; padding: 10px; }
button:hover { filter: brightness(.94); }
button:disabled { opacity: .5; cursor: wait; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
label input, label select { margin-top: 7px; }
.settings label { margin-bottom: 16px; }
details { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 14px 0; margin-bottom: 20px; font-size: 12px; }
summary { cursor: pointer; }
textarea { font-family: monospace; font-size: 12px; }
.row { display: flex; gap: 15px; }
.row > * { flex: 1; min-width: 0; }
input[type=color] { height: 36px; padding: 3px; width: 52px; margin: 0; }
.color { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }
.palette-swatches { display: flex; flex-wrap: wrap; gap: 4px; margin: -6px 0 8px; }
.palette-swatch { flex: 1 0 24px; max-width: 48px; height: 22px; border-radius: 3px; border: 1px solid #00000012; }
.settings input:disabled { background: var(--surface); color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 24px; }
#sharing { margin-top: 20px; border-top: 1px solid #ddd; padding-top: 16px; }
#sharing a { margin-left: 10px; color: var(--blue); }
.preview { min-width: 0; }
.previewbar { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 1px; color: var(--muted); padding: 14px 3px; }
article { padding: 30px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
article h2 { margin: 0; font-size: 27px; }
article p { font-size: 12px; margin-bottom: 28px; }
.canvas { height: 350px; position: relative; }
.chart-card { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.chart-card .canvas { min-width: 0; max-width: 100%; }
.chart-card canvas { display: block; max-width: 100%; }
.chart-annotations { position: absolute; pointer-events: none; z-index: 1; }
.chart-annotation { position: absolute; width: max-content; max-width: min(320px, 100%); max-height: 100%; overflow: auto; padding: 4px 6px; border-radius: 3px; line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; pointer-events: auto; }
.annotation-editable { cursor: grab; touch-action: none; user-select: none; }
.annotation-editable:hover { outline: 1px dashed var(--blue); }
.annotation-editable.annotation-selected { outline: 2px solid var(--blue); }
.annotation-editable:active { cursor: grabbing; }
.annotation-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.annotation-toolbar button { font-size: 12px; padding: 8px 12px; }
.annotation-toolbar span { color: var(--muted); font-size: 12px; }
#annotation-fields { margin-top: 18px; }
#annotation-fields input[type=color] { display: block; margin-top: 7px; }
.settings .toggle-field { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.toggle-field input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.preview-type-control { display: flex; align-items: center; gap: 10px; font-size: 11px; letter-spacing: 0; }
.preview-type-control select { width: auto; margin: 0; padding: 7px 10px; font-size: 12px; }
.preview .edit-hint { margin: 0 0 12px; text-align: left; }
.preview .chart-editable { cursor: text; border-radius: 4px; min-height: 1.5em; white-space: pre-wrap; }
.preview .chart-editable:hover { outline: 1px dashed #9ab6d7; outline-offset: 4px; }
.preview .chart-editable:focus { outline: 2px solid var(--blue); outline-offset: 4px; background: var(--surface); }
.preview .chart-editable:empty::before { content: attr(data-placeholder); color: var(--muted); font-weight: 400; }
footer { border-top: 1px solid #eee; padding-top: 17px; margin-top: 25px; font-size: 11px; color: var(--muted); }
.hint { text-align: center; font-size: 12px; }
.file { white-space: nowrap; font-size: 12px; }
#auth { max-width: 400px; margin: clamp(24px, 8vh, 90px) auto 0; }
#login { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 32px; }
#login h1 { font-size: 25px; letter-spacing: -.5px; }
#login > p { margin: 8px 0 28px; font-size: 13px; }
#login label { margin: 20px 0; }
#login button { width: 100%; margin-top: 10px; }
.auth-note { text-align: center; font-size: 12px; margin-top: 20px; }
#status { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 16px 24px; background: var(--blue-deep); color: #fff; border-radius: 8px; max-width: 90%; z-index: 10; }
[hidden] { display: none !important; }
@media (max-width: 1150px) {
  .workspace { grid-template-columns: 160px 1fr; }
  .preview { grid-column: 2; }
}
@media (max-width: 700px) {
  header { min-height: 68px; flex-wrap: wrap; gap: 12px; }
  .brand { font-size: 22px; }
  .brand span { font-size: 12px; }
  #account { font-size: 12px; width: 100%; justify-content: space-between; }
  #account:empty { display: none; }
  #account button { padding: 8px; }
  .workspace { display: flex; flex-direction: column; }
  #projects { display: flex; gap: 8px; overflow-x: auto; }
  #projects button { width: auto; max-width: 230px; flex-shrink: 0; white-space: nowrap; }
  main { padding: 24px 5%; }
  h1 { font-size: 28px; }
  .heading { gap: 15px; }
  .heading button { font-size: 12px; }
  #auth { margin-top: 24px; }
  #login { padding: 24px; }
  .editor { padding: 20px; }
  .imports { align-items: flex-start; flex-direction: column; }
  .google { flex-direction: column; }
  .canvas { height: 280px; }
  article { padding: 22px; }
}

/* Archive and guided editor. Scoped selectors also support older open pages. */
.studio-nav { display: flex; gap: 28px; border-bottom: 1px solid var(--border); margin: -12px 0 34px; }
.nav-link { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; color: var(--muted); padding: 16px 0; }
.nav-link[aria-current=page] { color: var(--blue); border-bottom-color: var(--orange); }
.heading > div { min-width: 0; }
.heading p { margin: 10px 0 0; }
.heading .eyebrow { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 1.5px; margin: 0 0 10px; }
.archive-tools { display: grid; grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(140px, 180px)); gap: 16px; align-items: end; padding: 20px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.archive-count { font-size: 12px; margin: 22px 0 12px; }
.archive-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.project-card { padding: 20px; min-width: 0; }
.project-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.type-tag { font-size: 11px; color: var(--muted); }
.badge { padding: 5px 9px; border-radius: 20px; background: var(--orange-soft); color: var(--orange-ink); font-size: 11px; font-weight: 600; }
.badge.published { color: var(--blue); background: var(--blue-soft); }
.chart-illustration { display: flex; justify-content: center; background: var(--surface); border-radius: 6px; }
.chart-illustration svg { width: 100%; max-width: 230px; height: 135px; display: block; }
.project-card .chart-illustration { margin: 18px 0; }
.project-card h2 { font-size: 19px; overflow-wrap: anywhere; }
.project-card p.project-description { font-size: 12px; margin: 8px 0 18px; height: 40px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.project-card p.project-date { font-size: 11px; margin: 0 0 18px; }
.project-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
#projects.archive-grid button { display: inline-block; width: auto; margin: 0; font-size: 12px; padding: 9px 13px; background: var(--blue); color: #fff; border: 0; text-align: center; }
#projects.archive-grid button.secondary { color: var(--blue); background: var(--blue-soft); border: 1px solid var(--border); }
#projects.archive-grid button.danger { background: transparent; color: #a63e37; margin-left: auto; }
.empty-state { text-align: center; padding: 60px 20px; border: 1px dashed var(--border); border-radius: 8px; background: #fff; }
.empty-state h2 { font-size: 23px; }
.empty-icon { font-size: 44px; color: var(--blue); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 20px; margin: 28px 0; font-size: 12px; }
.save-state { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
#save-state { font-size: 12px; color: var(--muted); }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); background: #fff; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 30px; overflow: hidden; }
.steps button { padding: 20px 16px; background: #fff; color: var(--muted); border-radius: 0; border-bottom: 3px solid transparent; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 13px; }
.steps button + button { border-left: 1px solid var(--border); }
.steps button span { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--blue-soft); color: var(--muted); flex-shrink: 0; font-size: 11px; }
.steps button[aria-current=step] { border-bottom-color: var(--orange); color: var(--blue-deep); background: var(--blue-soft); }
.steps button[aria-current=step] span { background: var(--orange); color: var(--blue-deep); }
.steps button:disabled { cursor: not-allowed; }
.steps button:focus-visible { outline-offset: -4px; }
.step-intro { margin: 0 0 28px; max-width: 750px; }
.type-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.type-card { background: #fff; color: var(--ink); padding: 24px; border: 1px solid var(--border); border-radius: 8px; text-align: left; display: flex; flex-direction: column; align-items: stretch; transition: border-color .15s, box-shadow .15s; }
.type-card:hover, .type-card[aria-pressed=true] { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); filter: none; }
.type-card .chart-illustration { margin-bottom: 24px; }
.type-name { font-size: 21px; margin-bottom: 10px; letter-spacing: -.4px; }
.type-purpose { font-size: 12px; color: var(--blue); margin-bottom: 9px; }
.type-description { font-size: 12px; font-weight: 400; color: var(--muted); line-height: 1.65; }
#edit-workspace { grid-template-columns: minmax(320px, 440px) minmax(0, 1fr); align-items: start; gap: 32px; }
#edit-workspace .preview { grid-column: auto; position: sticky; top: 20px; }
#edit-workspace .section-title { font-size: 17px; padding-bottom: 20px; margin-bottom: 20px; }
#edit-workspace .canvas { height: 370px; }
#edit-workspace .file { position: relative; overflow: hidden; display: inline-flex; align-items: center; }
#file:not([hidden]) { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; margin: 0; }
.file:focus-within { outline: 2px solid var(--blue); outline-offset: 3px; }
.data-help { font-size: 12px; margin: 10px 0 18px; }
#csv { margin: 0 0 10px; line-height: 1.5; resize: vertical; }
.pending-note { background: var(--orange-soft); border: 1px solid #f2c58f; color: var(--orange-ink); padding: 12px; border-radius: 5px; font-size: 12px; }
.selected-type { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.text-button { padding: 4px 8px; color: var(--blue); background: transparent; text-decoration: underline; font-size: 12px; }
#sharing .actions { align-items: center; }
#sharing a { margin: 0; font-size: 12px; }
dialog { padding: 28px; color: var(--ink); border: 1px solid var(--border); border-radius: 10px; max-width: min(560px, calc(100% - 32px)); }
dialog::backdrop { background: #16365c77; }
dialog h2 { margin: 0; font-size: 24px; }
@media (max-width: 1150px) {
  .type-grid, .archive-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .archive-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .search-label { grid-column: 1 / -1; }
  #edit-workspace { gap: 20px; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); }
  #edit-workspace .imports { align-items: flex-start; flex-direction: column; }
  #edit-workspace .google { flex-direction: column; }
}
@media (max-width: 760px) {
  .studio-nav { margin-bottom: 26px; }
  .builder-heading { align-items: flex-start; flex-direction: column; }
  .save-state { justify-content: space-between; width: 100%; }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .steps button { padding: 14px 8px; font-size: 12px; justify-content: flex-start; }
  .steps button:nth-child(3) { border-left: 0; }
  .steps button:nth-child(n+3) { border-top: 1px solid var(--border); }
  #edit-workspace { display: flex; flex-direction: column; }
  #edit-workspace > * { width: 100%; }
  #edit-workspace .preview { position: static; }
  #edit-workspace .canvas { height: 280px; }
  .type-grid { gap: 12px; }
  .type-card { padding: 16px; }
  .type-card .chart-illustration { margin-bottom: 16px; }
  .type-name { font-size: 19px; }
  .type-purpose, .type-description { font-size: 11px; }
  .type-card .chart-illustration svg { height: 110px; }
  #projects.archive-grid { display: grid; gap: 16px; overflow: visible; }
  #projects.archive-grid button { max-width: none; }
  .archive-grid { grid-template-columns: 1fr; }
  .archive-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 16px; }
  .archive-tools label:last-child { grid-column: 1 / -1; }
  #archive .heading { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 360px) {
  .type-grid { grid-template-columns: 1fr; }
}
