/* The Studio is a guided workspace: one set of choices beside one live preview. */
.theme-switcher { display: none; }
.studio-shell {
  width: min(1200px, calc(100% - 40px));
  margin-bottom: 48px;
}

.studio-shell [hidden] { display: none !important; }
.studio-shell :where(button, a, input, select, summary):focus-visible {
  outline: 2px solid var(--studio-gold);
  outline-offset: 4px;
}
.studio-shell :where(button, input, select):disabled {
  opacity: .46;
  cursor: not-allowed;
}
.studio-shell :where(button, a) { -webkit-tap-highlight-color: transparent; }
.studio-shell button { font-family: inherit; }
.studio-shell :where(input, select, label, fieldset) { min-width: 0; }
.studio-shell .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.studio-intro {
  padding: 34px 0 23px;
  align-items: center;
}
.studio-intro h1 {
  margin: 5px 0 9px;
  font-size: clamp(1.9rem, 3.9vw, 3rem);
  line-height: 1.12;
  letter-spacing: -.045em;
}
.studio-intro p:not(.eyebrow) {
  max-width: 660px;
  font-size: .97rem;
  line-height: 1.6;
}

.studio-progress { margin: 0 0 22px; }
.studio-progress ol {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.studio-progress li { min-width: 0; }
.studio-progress button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 57px;
  padding: 10px 12px;
  border: 1px solid rgba(143, 214, 255, .12);
  border-radius: 12px;
  color: #92a5b8;
  background: rgba(12, 18, 29, .58);
  text-align: left;
  cursor: pointer;
}
.studio-progress button:hover:not(:disabled) {
  border-color: rgba(143, 214, 255, .4);
  color: #e7f4ff;
}
.studio-progress .step-number {
  display: grid;
  flex: 0 0 28px;
  height: 28px;
  place-items: center;
  border: 1px solid rgba(143, 214, 255, .18);
  border-radius: 50%;
  color: #a9bdce;
  font-size: .76rem;
  font-weight: 800;
}
.studio-progress .step-label { font-size: .83rem; font-weight: 650; }
.studio-progress :is(li.is-current button, button.is-current) {
  border-color: rgba(143, 214, 255, .66);
  color: #eaf6ff;
  background: rgba(143, 214, 255, .09);
}
.studio-progress :is(li.is-current, button.is-current) .step-number {
  color: #07121d;
  background: var(--studio-blue);
  border-color: var(--studio-blue);
}
.studio-progress :is(li.is-complete, button.is-complete) .step-number {
  border-color: rgba(143, 214, 255, .48);
  color: var(--studio-blue);
}

#studio.studio-grid {
  grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
  gap: 22px;
}
.workflow-panel,
#studio .preview-panel {
  min-width: 0;
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .15);
}
.workflow-panel { background: rgba(12, 18, 29, .94); }
.studio-step { padding: 25px 24px 23px; }
.step-kicker {
  margin: 0 0 7px;
  color: var(--studio-blue);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.step-title {
  margin: 0 0 9px;
  color: #f0f7ff;
  font-size: 1.4rem;
  line-height: 1.25;
  letter-spacing: -.025em;
  scroll-margin-top: 100px;
}
.step-description {
  margin: 0 0 22px;
  color: #a6b7c8;
  font-size: .88rem;
  line-height: 1.65;
}
.step-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.step-actions > :is(button, a) { flex: 1 1 140px; }
.studio-shell :is(.primary-action, .secondary-action) {
  min-height: 43px;
  font-size: .87rem;
  line-height: 1.4;
  cursor: pointer;
}
.studio-shell .primary-action:hover:not(:disabled) { filter: brightness(1.08); text-decoration: none; }
.studio-shell .secondary-action:hover:not(:disabled) { background: rgba(143, 214, 255, .14); text-decoration: none; }
.workflow-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 17px 24px;
  border-top: 1px solid rgba(143, 214, 255, .12);
  background: rgba(5, 8, 14, .32);
}
.workflow-footer > button { min-width: 96px; }
#studioNext { margin-left: auto; }

.workflow-panel #authGate {
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  text-align: left;
}
#authGate .gate-icon { display: none; }
#authGate h2 { font-size: 1rem; margin: 0 0 7px; }
#authGate p { color: #a6b7c8; font-size: .86rem; line-height: 1.6; margin: 0 0 17px; }
#authGate .primary-action { width: 100%; }
#skipSignIn { width: 100%; margin-top: 10px; }
.workflow-panel .connection-panel {
  display: block;
  margin: 24px 0 0;
  padding: 17px 0 0;
  border: 0;
  border-top: 1px solid rgba(143, 214, 255, .12);
  border-radius: 0;
  background: none;
}
.connection-details h2 { font-size: .8rem; color: #c3d3e2; }
.connection-details p { font-size: .78rem; line-height: 1.55; }
.connection-panel #testDiscordConnection { margin-top: 12px; padding: 8px 11px; min-height: 36px; font-size: .77rem; }

.version-options {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  margin: 0 0 13px;
}
.version-picker { min-width: 0; margin: 0; padding: 0; border: 0; }
.version-picker > legend { margin-bottom: 12px; color: #aebdcd; font-size: .82rem; }
.version-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 46px;
  padding: 10px 34px 10px 12px;
  border: 1px solid rgba(143, 214, 255, .17);
  border-radius: 10px;
  background: rgba(5, 8, 14, .35);
  cursor: pointer;
}
.workflow-panel .version-option input[type=radio] {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 10px;
  left: auto;
  max-width: 15px;
  width: 15px;
  height: 15px;
  margin: 0;
  padding: 0;
  accent-color: var(--studio-blue);
}
.version-option strong { font-size: .84rem; line-height: 1.35; color: #e2edf8; }
.version-option small { margin-left: auto; text-align: right; color: #8fa4b8; font-size: .7rem; line-height: 1.5; }
.version-option:has(input:checked) {
  border-color: var(--studio-blue);
  background: rgba(143, 214, 255, .08);
  box-shadow: inset 0 0 0 1px rgba(143, 214, 255, .1);
}
.version-option:hover { border-color: rgba(143, 214, 255, .5); }
.version-note { color: #c9b78e; font-size: .79rem; line-height: 1.6; margin: 0 0 17px; }
.workflow-panel .manual-grid { padding-top: 0; }
.workflow-panel :is(.manual-grid label, .studio-step > label) { font-size: .8rem; }
.workflow-panel .control-note { font-size: .79rem; line-height: 1.6; }
.workflow-panel .region-picker { margin: 18px 0 13px; }
.workflow-panel .inline-status { overflow-wrap: anywhere; }

.workflow-panel #backgroundChooser {
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}
.workflow-panel #backgroundGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  overflow: visible;
  scroll-snap-type: none;
}
.workflow-panel .background-option {
  display: block;
  min-width: 0;
  min-height: 86px;
  width: 100%;
  padding: 3px;
  border-radius: 10px;
}
.workflow-panel .background-option img { aspect-ratio: 16 / 10; }
.workflow-panel .no-background-option { display: grid; place-items: center; }
.workflow-panel .no-background-option > span { font-size: .74rem; padding: 4px 8px; }
.workflow-panel .background-upload-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  min-height: 86px;
  padding: 12px 8px;
  border: 1px dashed rgba(143, 214, 255, .45);
  border-radius: 10px;
  color: #d4eafa;
  background: rgba(143, 214, 255, .035);
  font-size: .77rem;
  cursor: pointer;
}
.background-upload-tile .plus-icon { color: var(--studio-blue); font-size: 1.8rem; font-weight: 400; line-height: 1; }
.background-upload-tile:hover:not(:disabled) { border-color: var(--studio-blue); background: rgba(143, 214, 255, .09); }
.custom-background-slot { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.workflow-panel .custom-background-slot .background-upload-tile { width: 100%; flex: 1; }
.background-custom-option {
  width: 100%; padding: 3px; border: 1px solid rgba(143, 214, 255, .3); border-radius: 10px;
  color: #d4eafa; background: rgba(143, 214, 255, .035); cursor: pointer; overflow: hidden;
}
.background-custom-option canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; border-radius: 7px; background: #111827; }
.background-custom-option strong { display: block; padding: 6px 3px; font-size: .72rem; line-height: 1.3; }
.background-custom-option.active, .background-custom-option:hover:not(:disabled) { border-color: var(--studio-blue); background: rgba(143, 214, 255, .12); }
.background-custom-option:focus-visible { outline: 2px solid var(--studio-gold); outline-offset: 3px; }
.background-custom-option:disabled { cursor: not-allowed; opacity: .6; }
.custom-background-slot:has(.background-custom-option:not([hidden])) .background-upload-tile { min-height: 40px; flex-direction: row; padding: 7px; }
.custom-background-slot:has(.background-custom-option:not([hidden])) .plus-icon { font-size: 1.1rem; }
.custom-slot-usage { color: #91a6ba; font-size: .7rem; text-align: center; }
.studio-shell #backgroundUpload.visually-hidden { width: 1px; min-width: 0; max-width: 1px; height: 1px; padding: 0; border: 0; }
.workflow-panel .background-extras { margin-top: 18px; padding: 0; }
.workflow-panel .background-extras label { display: grid; gap: 5px; color: #acbdcd; }
.workflow-panel .background-extras output { float: right; color: #eef6ff; }
.workflow-panel .saved-photo-toggle { margin-top: 18px; font-size: .81rem; }
.workflow-panel .saved-photo-status { margin-bottom: 9px; }
.upload-details { margin-top: 16px; padding-top: 13px; border-top: 1px solid rgba(143, 214, 255, .1); }
.upload-details summary { font-size: .77rem; }
.workflow-panel .upload-feedback { margin-top: 12px; }
.workflow-panel .upload-status { flex-basis: 180px; }
.workflow-panel .style-picker { margin: 0 0 12px; }
.workflow-panel .style-picker { display: grid; grid-template-columns: 1fr; gap: 8px; }
.workflow-panel .style-option { display: flex; align-items: center; gap: 10px; text-align: left; }
.workflow-panel .style-option::before { content: ''; display: inline-block; width: 17px; height: 17px; border: 1px solid currentColor; border-radius: 4px; text-align: center; line-height: 16px; flex: 0 0 17px; }
.workflow-panel .style-option[aria-checked="true"]::before { content: '✓'; }
.workflow-panel .style-description { font-size: .8rem; line-height: 1.6; }
.workflow-panel .layout-settings { border-radius: 10px; }
.workflow-panel .layout-settings > summary { padding: 12px; font-size: .81rem; }
.workflow-panel .settings-fields { padding: 14px 12px; }
.workflow-panel .setting-toggle { display: flex; align-items: center; gap: 9px; }
.workflow-panel .setting-toggle input[type=checkbox] { flex: 0 0 18px; width: 18px; height: 18px; margin: 0; accent-color: var(--studio-blue); }
.gear-note { margin: 15px 0; padding: 12px; border-radius: 9px; color: #a5b8ca; background: rgba(143, 214, 255, .04); font-size: .79rem; line-height: 1.6; }
.gear-note strong { color: #d6e5f2; }
.review-summary { margin: 0 0 20px; }
.review-summary > div { display: grid; grid-template-columns: 85px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(143, 214, 255, .1); }
.advanced-settings > div { display: grid; gap: 12px; margin-top: 12px; }
.advanced-settings label { display: grid; gap: 6px; color: #acbdcd; font-size: .79rem; }
.advanced-settings output { float: right; color: #eef6ff; }
.review-summary dt { color: #8fa5ba; font-size: .8rem; }
.review-summary dd { margin: 0; color: #e3eef8; font-size: .83rem; overflow-wrap: anywhere; }
.workflow-panel .save-requirement { margin: 17px 0; padding: 12px; line-height: 1.6; }
.workflow-panel #saveDesign,
.workflow-panel #downloadImage { width: 100%; margin-top: 10px; }
.workflow-panel .save-status { margin-top: 14px; overflow-wrap: anywhere; }

#studio .preview-panel { padding: 17px; top: 96px; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; color: #b9cddd; font-size: .81rem; }
.preview-heading > div { min-width: 0; }
.preview-heading #backgroundTrigger { width: auto; min-height: 34px; padding: 7px 10px; border: 1px solid rgba(143, 214, 255, .18); border-radius: 8px; background: rgba(143, 214, 255, .05); color: #c4dff0; font: inherit; font-size: .74rem; cursor: pointer; }
.preview-heading .live-dot { width: 6px; height: 6px; margin-right: 6px; box-shadow: none; }
#studio .canvas-wrap { min-height: 350px; border-radius: 12px; }
#studio canvas { max-height: calc(100vh - 270px); }
.empty-preview { padding: 20px; }
.empty-preview strong { font-size: .96rem; }
.empty-preview small { max-width: 250px; margin: 0 auto; line-height: 1.6; }
#studio .character-meta { margin-top: 12px; gap: 8px; font-size: .72rem; }
#studio .character-meta > span { min-width: 0; overflow-wrap: anywhere; }
.preview-panel .draft-notice { justify-items: start; gap: 6px; margin-top: 15px; padding-top: 13px; border-top: 1px solid rgba(143, 214, 255, .1); }
.preview-panel .draft-status { padding: 0; border: 0; border-radius: 0; color: #8fa6b9; font-size: .74rem; white-space: normal; }
.preview-panel .draft-restore { font-size: .74rem; }

@media (max-width: 950px) and (min-width: 761px) {
  #studio.studio-grid { grid-template-columns: minmax(0, 350px) minmax(0, 1fr); gap: 16px; }
  #studio .preview-panel { position: sticky; grid-row: auto; }
  #studio .canvas-wrap { min-height: 280px; }
  .studio-progress button { gap: 7px; padding: 9px; }
  .studio-progress .step-label { font-size: .76rem; }
}

@media (max-width: 760px) {
  .studio-shell { width: calc(100% - 28px); margin-bottom: 30px; }
  .studio-header { height: 68px; padding: 0 14px; }
  .studio-brand { gap: 9px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
  .studio-brand strong { font-size: .9rem; }
  .studio-brand small { font-size: .71rem; }
  .account-state { max-width: 140px; font-size: .74rem; overflow-wrap: anywhere; }
  .studio-intro { padding: 26px 0 20px; gap: 10px; }
  .studio-intro p:not(.eyebrow) { font-size: .86rem; }
  .studio-progress { margin-bottom: 16px; }
  .studio-progress ol { gap: 5px; }
  .studio-progress button { flex-direction: column; justify-content: center; gap: 5px; min-height: 66px; padding: 8px 3px; text-align: center; border-radius: 10px; }
  .studio-progress .step-number { flex-basis: auto; width: 25px; height: 25px; font-size: .72rem; }
  .studio-progress .step-label { font-size: .65rem; line-height: 1.3; }
  #studio.studio-grid { grid-template-columns: minmax(0, 1fr); gap: 17px; }
  #studio .preview-panel { grid-row: auto; position: static; padding: 14px; }
  .studio-step { padding: 22px 20px; }
  .step-title { font-size: 1.3rem; }
  .step-description { margin-bottom: 18px; }
  .workflow-footer { padding: 16px 20px; }
  #studio .canvas-wrap { min-height: 250px; }
  #studio canvas { max-height: none; }
  #studio .character-meta { flex-direction: row; flex-wrap: wrap; }
  .workflow-panel .background-option { min-height: 88px; }
}

@media (max-width: 380px) {
  .studio-shell { width: calc(100% - 20px); }
  .studio-step { padding: 20px 16px; }
  .workflow-footer { padding: 15px 16px; }
  .studio-progress .step-label { font-size: .6rem; }
  .account-state { max-width: 115px; }
  .preview-heading { font-size: .76rem; }
  .preview-heading #backgroundTrigger { font-size: .68rem; padding-inline: 7px; }
}

/* Sign-in is one task card; the editing workspace appears after continuing. */
html[data-current-studio-step="1"] :is(.studio-intro, .studio-progress, .preview-panel, #saveStatus, .account-state) { display: none !important; }
html[data-current-studio-step="1"] .studio-grid { display: block; max-width: 440px; margin: 24px auto; }
html[data-current-studio-step="1"] .workflow-panel .connection-panel { margin: 14px 0 0; padding: 0; border: 0; }
html[data-current-studio-step="1"] #authGate :is(#gateTitle, #gateCopy),
html[data-current-studio-step="1"] #connectionTitle { display: none; }
html[data-current-studio-step="1"] #skipSignIn { min-height: 44px; background: transparent; border: 0; }
html[data-current-studio-step="1"] .step-description { margin-bottom: 18px; }

/* Character selection is a form; the card preview begins with Style. */
html[data-current-studio-step="2"] .preview-panel { display: none !important; }
html[data-current-studio-step="2"] .studio-grid { display: block; max-width: 440px; margin-inline: auto; }
.workflow-panel #regionButtons { display: flex; gap: 8px; }
.workflow-panel #regionButtons .region-button { flex: 0 0 auto; width: auto; min-width: 68px; min-height: 44px; padding: 7px 12px; font-size: .8rem; }

.region-flag { width: 20px; height: 14px; flex: 0 0 20px; border-radius: 2px; }
.workflow-panel #regionButtons .region-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }

/* A single swipeable row keeps background choices above the portrait. */
html[data-current-studio-step="4"] #studio.studio-grid { display: flex; flex-direction: column; max-width: 900px; margin-inline: auto; }
html[data-current-studio-step="4"] #studio > :is(.workflow-panel, .preview-panel) { width: 100%; min-width: 0; }
.background-carousel-controls { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.background-carousel-controls > span { margin-right: auto; color: #a6b7c8; font-size: .78rem; }
.background-carousel-controls button { width: 44px; min-height: 44px; border: 1px solid rgba(143,214,255,.2); border-radius: 9px; font-size: 1.2rem; }
.workflow-panel #backgroundGrid { display: flex; flex-wrap: nowrap; gap: 10px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; overscroll-behavior-x: contain; padding: 4px 3px 12px; scrollbar-width: thin; }
.workflow-panel #backgroundGrid > :is(.background-option, .custom-background-slot) { flex: 0 0 clamp(130px, 36vw, 180px); width: clamp(130px, 36vw, 180px); scroll-snap-align: start; }
.workflow-panel #backgroundGrid > .background-option { align-self: flex-start; }
.workflow-panel #backgroundGrid .background-option img { display: block; width: 100%; height: auto; object-fit: cover; }
@media (prefers-reduced-motion: reduce) { .workflow-panel #backgroundGrid { scroll-behavior: auto; } }

.background-carousel-controls { justify-content: flex-end; }
.workflow-panel .upload-feedback:has(.upload-status[hidden]):has(.upload-remove[hidden]) { display: none; }

.workflow-panel #resetDraft { display: inline-block; margin-top: 24px; margin-bottom: 4px; }
