/* Character creator. Rules are scoped to .creator-page; /styles.css owns the shared header and footer.
   See site/DESIGN.md, "Creator workspace", for the principles these values implement. */
.creator-page {
  --space-1: .236rem; --space-2: .382rem; --space-3: .618rem; --space-4: 1rem;
  --space-5: 1.618rem; --space-6: 2.618rem; --space-7: 4.236rem;
  --field: #f2f2f5;
  --hover: #ececf0;
  --selected: #e3e3e8;
  --ring: #c3c3c9;
  --muted: #5c5c62;
  --accent-soft: rgb(21 89 193 / .09);
  --danger: #b4232f;
  --on-accent: #fff;
  --raised: 0 1px 2px rgb(0 0 0 / .06), 0 .618rem 1.618rem rgb(0 0 0 / .1);
  background: var(--white);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .creator-page {
    --field: #2a2a2d; --hover: #2c2c2f; --selected: #38383c; --ring: #5a5a5f; --muted: #b8b8bd;
    --accent-soft: rgb(110 175 255 / .14); --danger: #ff8a95; --on-accent: #08182c;
    --raised: 0 0 0 1px rgb(255 255 255 / .07), 0 .618rem 1.618rem rgb(0 0 0 / .5);
  }
}
:root[data-theme="dark"] .creator-page {
  --field: #2a2a2d; --hover: #2c2c2f; --selected: #38383c; --ring: #5a5a5f; --muted: #b8b8bd;
  --accent-soft: rgb(110 175 255 / .14); --danger: #ff8a95; --on-accent: #08182c;
  --raised: 0 0 0 1px rgb(255 255 255 / .07), 0 .618rem 1.618rem rgb(0 0 0 / .5);
}
.creator-page .site-footer { background: var(--paper); }
.creator-page [hidden] { display: none !important; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Workspace: the outline beside one focused step. The min-height keeps the footer below a short step. */
.creator { display: grid; grid-template-columns: 16.18rem minmax(0, 1fr); column-gap: var(--space-7); align-items: start; align-content: start; min-height: calc(100vh - 44px); padding: var(--space-6) 0 var(--space-7); font-size: 17px; line-height: 1.45; }

/* Outline */
.outline { position: sticky; top: calc(53px + var(--space-5)); padding: var(--space-3); border-radius: 14px; background: var(--paper); }
.draft-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3) var(--space-4); }
.draft-copy { min-width: 0; }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; flex: none; overflow: hidden; border-radius: 10px; background: var(--selected); color: var(--muted); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
/* A glyph is its own shape, like the app's agent avatars, so it sits on no tile. */
.avatar.has-glyph { background: none; }
.avatar .glyph-image, .glyph-image.thumb { object-fit: contain; border-radius: 0; }
.avatar-small { width: 28px; height: 28px; border-radius: 7px; }
.avatar-small .i { width: 16px; height: 16px; }
.avatar-large { width: 72px; height: 72px; border-radius: 16px; }
.avatar-large .i { width: 30px; height: 30px; }
.draft-name { display: block; overflow: hidden; color: var(--ink); font-size: 17px; font-weight: 600; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.draft-status { display: block; color: var(--muted); font-size: 15px; line-height: 1.3; }
.steps { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.step-link { display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: var(--space-3); align-items: center; width: 100%; padding: var(--space-2) var(--space-3); border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; font-size: 16px; line-height: 1.3; text-align: left; cursor: pointer; }
.step-link:hover { background: var(--hover); }
.step-link[aria-current="step"] { background: var(--selected); }
.step-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.step-link:disabled { color: var(--muted); cursor: default; }
.step-link:disabled:hover { background: none; }
.step-link .pie { grid-row: 1 / span 2; }
.step-label { font-weight: 500; }
.step-summary { overflow: hidden; color: var(--muted); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.steps-locked { margin: var(--space-2) var(--space-3) 0; color: var(--muted); font-size: 15px; line-height: 1.4; }
.outline-bar { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-4); padding-top: var(--space-3); border-top: 1px solid var(--line); }
.bar-button { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 36px; padding: 0 var(--space-3); border: 0; border-radius: 8px; background: none; color: var(--muted); font: inherit; font-size: 16px; cursor: pointer; }
.bar-button:hover, .bar-button[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.count { font-variant-numeric: tabular-nums; }

/* Drafts popover, anchored above the outline's bottom bar. */
.outline-panel { position: relative; }
.popover { position: absolute; z-index: 5; right: 0; bottom: calc(36px + var(--space-3) + var(--space-2)); left: 0; max-height: min(26rem, 70vh); overflow: auto; padding: var(--space-3); border: 1px solid var(--line); border-radius: 12px; background: var(--white); box-shadow: var(--raised); }
.popover-title { margin: var(--space-1) var(--space-3) var(--space-2); font-size: 15px; font-weight: 600; line-height: 1.3; }
.draft-list { display: flex; flex-direction: column; gap: 2px; }
.draft-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; column-gap: var(--space-3); align-items: center; width: 100%; padding: var(--space-2) var(--space-3); border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; font-size: 16px; text-align: left; cursor: pointer; }
.draft-row:hover { background: var(--hover); }
.draft-row[aria-current="true"] { background: var(--selected); }
.draft-row:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.draft-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-row-date { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.popover-empty { margin: 0 var(--space-3) var(--space-2); color: var(--muted); font-size: 15px; }
.popover-foot { margin-top: var(--space-2); padding: var(--space-2) var(--space-3) 0; border-top: 1px solid var(--line); }
.popover-foot .add-row { margin: 0 0 0 calc(-1 * var(--space-3)); }
.popover-status { margin: 0; color: var(--muted); font-size: 15px; }
.popover-status:empty { display: none; }

/* Progress pie */
.pie { width: 20px; height: 20px; color: var(--accent); }
.pie circle.track { fill: none; stroke: var(--ring); stroke-width: 1.5; }
.pie .wedge { fill: currentColor; }
.pie.done circle.fill { fill: currentColor; }
.pie.done path.tick { fill: none; stroke: var(--white); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pie-slot { display: inline-flex; flex: none; }
.pie-large .pie, .pie-large .title-icon { width: 28px; height: 28px; }
.title-icon { color: var(--muted); stroke-width: 1.6; }

/* Step pane */
.pane { min-width: 0; max-width: 44rem; padding-top: var(--space-3); }
.step-head { margin-bottom: var(--space-6); scroll-margin-top: calc(53px + var(--space-5)); }
.pane { scroll-margin-top: calc(53px + var(--space-5)); }
.step-title { display: flex; align-items: center; gap: var(--space-3); max-width: none; margin: 0; font-size: 30px; font-weight: 700; line-height: 1.15; }
.step-title:focus { outline: none; }
.step-title:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 6px; }
.step-note { margin: var(--space-3) 0 0 calc(28px + var(--space-3)); color: var(--muted); font-size: 18px; line-height: 1.45; }
.origin { margin: var(--space-2) 0 0 calc(28px + var(--space-3)); color: var(--muted); font-size: 15px; }
.step-body { margin-left: calc(28px + var(--space-3)); }
.step-panel:has(.back-row:first-child) { margin-top: calc(-1 * var(--space-4)); }

.field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }
.field > label, .label { color: var(--secondary); font-size: 15px; font-weight: 600; }
.input { display: block; width: 100%; padding: var(--space-3) var(--space-4); border: 1px solid transparent; border-radius: 10px; background: var(--field); color: var(--ink); font: inherit; font-size: 17px; line-height: 1.5; }
textarea.input { min-height: 6.5rem; line-height: 1.618; resize: vertical; }
.input::placeholder { color: var(--muted); opacity: .8; }
.input:focus { outline: none; border-color: var(--accent); background: var(--white); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input-name { font-size: 26px; font-weight: 600; }
.field-help { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.field-help:empty { display: none; }
.field-error { margin: 0; color: var(--danger); font-size: 15px; line-height: 1.45; }

/* Quiet "Add …" controls reveal optional fields in place. */
.add-row { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3) calc(-1 * var(--space-3)); padding: var(--space-2) var(--space-3); border: 0; border-radius: 8px; background: none; color: var(--muted); font: inherit; font-size: 16px; line-height: 1.3; cursor: pointer; }
.add-row:hover { background: var(--accent-soft); color: var(--accent); }
.add-group { display: flex; flex-wrap: wrap; column-gap: var(--space-4); }
.add-group:not(:has(> .add-row:not([hidden]))) { display: none; }
.section-head .add-row { margin: 0 calc(-1 * var(--space-3)) 0 0; }
input.visually-hidden:focus-visible + .add-row { outline: 2px solid var(--focus); outline-offset: 2px; }
.link-button { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; }
.link-button:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

/* A heading inside a step, after Things: accent text over one hairline. */
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 2.25rem; margin: var(--space-6) 0 0; padding-bottom: var(--space-1); border-bottom: 1px solid var(--line); }
.step-panel > .section-head:first-child { margin-top: 0; }
.section-head h2 { margin: 0; color: var(--accent); font-size: 17px; font-weight: 600; line-height: 1.3; }
.section-help { margin: var(--space-2) 0 0; color: var(--muted); font-size: 15px; }

/* Quiet rows that open into a card */
.rows { display: flex; flex-direction: column; margin: var(--space-2) calc(-1 * var(--space-3)) var(--space-3); }
.row, .row-open { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; column-gap: var(--space-3); align-items: start; width: 100%; padding: var(--space-3); border: 0; border-radius: 10px; background: none; color: var(--ink); font: inherit; text-align: left; }
button.row, .row-open { cursor: pointer; }
button.row:hover, .row-open:hover { background: var(--hover); }
button.row:focus-visible, .row-open:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.row .glyph { margin-top: 3px; color: var(--muted); }
.row-copy { min-width: 0; }
.row-title { display: block; overflow: hidden; font-size: 17px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.row-excerpt { display: block; overflow: hidden; color: var(--muted); font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.row-excerpt.is-missing { font-style: italic; }
.row-meta { align-self: center; color: var(--muted); font-size: 15px; white-space: nowrap; }
.chevron { align-self: center; color: var(--muted); }
.scene-row { grid-template-columns: 22px minmax(0, 1fr); padding: 0 0 0 var(--space-3); }
.scene-row input, .choice input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.scene-row input { margin-top: calc(var(--space-3) + 3px); }
.scene-row .row-open { grid-template-columns: minmax(0, 1fr) auto; margin-left: calc(-1 * var(--space-2)); padding-left: var(--space-2); }
.scene-row .row-meta { color: var(--accent); font-weight: 500; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.image-row, .source-row { grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; }
.image-row { padding-block: var(--space-2); }
.image-rows { margin-bottom: var(--space-2); }
.image-rows:empty { display: none; }
.source-row .glyph { justify-self: center; width: 24px; height: 24px; margin: 0; }

.card { margin: var(--space-2) calc(-1 * var(--space-2)) var(--space-3); padding: var(--space-4) var(--space-5); border-radius: 12px; background: var(--white); box-shadow: var(--raised); }
.card-title { display: block; width: 100%; margin: 0 0 var(--space-4); padding: var(--space-1) 0 var(--space-2); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; color: var(--ink); font: inherit; font-size: 19px; font-weight: 600; }
.card-title::placeholder { color: var(--muted); font-weight: 500; opacity: .8; }
.card-title:focus { outline: none; border-bottom-color: var(--accent); }
.card .field { margin-bottom: var(--space-4); }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.card-foot .btn-danger { margin-left: calc(-1 * var(--space-4)); }
.card-actions { display: inline-flex; gap: var(--space-2); margin-left: auto; }
.choice { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--ink); font-size: 16px; cursor: pointer; }

/* Buttons: one blue primary per step. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 38px; padding: 0 var(--space-4); border: 0; border-radius: 9px; font: inherit; font-size: 16px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn-primary { background: var(--accent); color: var(--on-accent); font-weight: 600; box-shadow: 0 1px 1px rgb(0 0 0 / .08); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--field); color: var(--ink); }
.btn-secondary:hover { background: var(--selected); }
.btn-quiet { background: none; color: var(--muted); }
.btn-quiet:hover { background: var(--hover); color: var(--ink); }
.btn-danger { background: none; color: var(--danger); }
.btn-danger:hover { background: var(--hover); }
.btn:disabled { background: var(--field); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.btn:focus-visible, .add-row:focus-visible, .bar-button:focus-visible, .link-button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.step-foot { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-6); }
.step-foot .spacer { flex: 1; }

/* Picker */
.back-row { margin-bottom: var(--space-4); }
.search-wrap { position: relative; display: block; }
.search-wrap .i { position: absolute; top: 50%; left: var(--space-4); color: var(--muted); transform: translateY(-50%); pointer-events: none; }
.search-wrap .input { padding-left: calc(var(--space-4) + 18px + var(--space-3)); }
.search-field { margin-bottom: var(--space-3); }

/* Review */
.review-hero { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); }
.review-hero h2 { margin: 0; font-size: 24px; line-height: 1.2; }
.review-hero p { margin: var(--space-1) 0 0; color: var(--muted); font-size: 17px; }
.review-hero p:empty { display: none; }
.review-list { border-top: 1px solid var(--line); }
.review-row { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr) auto; column-gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.review-key { color: var(--secondary); font-size: 15px; font-weight: 600; line-height: 1.75; }
.review-value { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 17px; }
.review-value .i { width: 17px; height: 17px; vertical-align: -3px; }
.review-row .link-button { align-self: start; font-size: 16px; line-height: 1.6; }
.review-row.is-empty .review-value, .review-row.is-advisory .review-value { color: var(--muted); }
.review-row.is-blocking .review-value { color: var(--danger); }
.export { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-6); }
.export-note { flex-basis: 100%; margin: var(--space-1) 0 0; color: var(--muted); font-size: 15px; }
.export-note:empty { display: none; }
.export-blocked { color: var(--danger); }

/* Narrow: the outline becomes a bar that opens in place above the step. */
.outline-toggle { display: none; }
@media (max-width: 900px) {
  .creator { grid-template-columns: minmax(0, 1fr); padding-top: 0; }
  .outline { top: 53px; z-index: 4; margin: 0 -24px; padding: 0; border-radius: 0; }
  .outline-toggle { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 52px; padding: 0 24px; border: 0; background: none; color: var(--ink); font: inherit; font-size: 17px; font-weight: 600; text-align: left; cursor: pointer; }
  .outline-toggle:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
  .toggle-position { margin-left: auto; color: var(--muted); font-size: 15px; font-weight: 400; }
  .outline-toggle[aria-expanded="true"] > .i { transform: rotate(180deg); }
  .outline-panel { display: none; max-height: calc(100vh - 53px - 52px); overflow: auto; padding: 0 var(--space-4) var(--space-3); }
  .outline.open .outline-panel { display: block; }
  .popover { position: static; margin-top: var(--space-3); box-shadow: none; }
  .pane { padding-top: var(--space-5); }
  .step-title { font-size: 26px; }
  .step-note, .origin, .step-body { margin-left: 0; }
  .step-foot { flex-wrap: wrap; }
  .step-foot .btn-primary { order: -1; flex-basis: 100%; min-height: 44px; }
  .step-foot .spacer { display: none; }
  .review-row { grid-template-columns: minmax(0, 1fr) auto; }
  .review-key { grid-column: 1 / -1; }
  .card { margin-inline: calc(-1 * var(--space-3)); padding: var(--space-4); }
}
@media (max-width: 620px) {
  .outline { margin: 0 -18px; }
  .outline-toggle { padding: 0 18px; }
  .source-row .row-meta { display: none; }
  .source-row { grid-template-columns: 44px minmax(0, 1fr); }
}
