.builder-role-hidden,
.builder-legacy-description-hidden {
  display: none !important;
}

.builder-character-card-fixed {
  position: relative;
}

[data-characters-box] > .panel + .panel,
[data-characters-box] > section + section,
.builder-character-card-fixed + .builder-character-card-fixed {
  margin-top: 22px !important;
  padding-top: 24px !important;
  border-top: 1px solid #353535 !important;
}

.builder-character-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.builder-character-delete,
.button.builder-character-delete,
.button.danger.builder-character-delete {
  border-color: rgba(255, 70, 70, .55) !important;
  color: #ff8b8b !important;
  background: rgba(120, 16, 16, .34) !important;
}

.builder-character-sexual-block.hidden {
  display: none !important;
}

.builder-character-nsfw-fields [data-character-block='sexualPreference'] {
  margin-top: 14px;
}

.builder-character-line-head {
  display: grid !important;
  grid-template-columns: minmax(56px, auto) minmax(220px, 1fr) 78px auto auto !important;
  align-items: center !important;
  gap: 10px !important;
}

.builder-character-line-head > label:first-child,
.builder-character-line-head .inline-label,
.builder-character-summary-label {
  white-space: nowrap !important;
  min-width: max-content !important;
}

.builder-character-line-head .inline-label {
  display: inline-grid !important;
  grid-template-columns: max-content minmax(180px, 1fr) !important;
  align-items: center !important;
  gap: 8px !important;
}

.builder-character-line-head .inline-label input {
  min-width: 0 !important;
  width: 100% !important;
}

.builder-character-line-head .builder-token-input {
  width: 78px !important;
  min-width: 78px !important;
  text-align: center !important;
}

.builder-character-line-head .hint {
  white-space: nowrap !important;
}

.builder-privacy-field {
  margin: 14px 0 16px !important;
}

.builder-privacy-field label {
  display: block !important;
  margin-bottom: 8px !important;
  font-weight: 800 !important;
}

.builder-privacy-field select {
  width: 100% !important;
}

.builder-preview-restored-layout {
  display: grid !important;
  grid-template-columns: minmax(520px, .54fr) minmax(360px, .46fr) !important;
  min-height: calc(100vh - var(--topbar, 56px)) !important;
}

.builder-preview-pane-restored {
  min-width: 0 !important;
  border-left: 1px solid #333 !important;
}

.unsafe-help {
  margin: 8px 0 16px !important;
  padding: 12px 14px !important;
  border: 1px solid rgba(255, 73, 73, .45);
  border-radius: 8px;
  color: #ffb0b0 !important;
  background: rgba(255, 57, 57, .11);
  font-weight: 800;
}

[data-info-color] option {
  font-weight: 800;
}

.model-combobox {
  position: relative;
  width: 100%;
  min-width: 0;
}

.model-native-select {
  position: absolute !important;
  inset: 0 auto auto 0 !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 1px !important;
  min-height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
}

.model-combobox-button {
  width: 100%;
  min-height: 44px;
  display: block;
  position: relative;
  border: 1px solid #343434;
  border-radius: 10px;
  background: #050505;
  color: #fff;
  padding: 0 38px 0 12px;
  text-align: left;
  font: inherit;
  font-weight: 800;
  line-height: 1.2;
  box-shadow: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-combobox-button::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #cfcfcf;
  border-bottom: 2px solid #cfcfcf;
  transform: translateY(-65%) rotate(45deg);
}

.model-combobox.is-open .model-combobox-button {
  border-color: #666;
}

.model-combobox-list {
  display: none;
  position: absolute;
  z-index: 120;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-width: calc(100vw - 24px);
  max-height: min(260px, 42vh);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #444;
  border-radius: 10px;
  background: #080808;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .55);
  padding: 6px;
}

.model-combobox.is-open .model-combobox-list {
  display: block;
}

.model-combobox.open-up .model-combobox-list {
  top: auto;
  bottom: calc(100% + 6px);
}

.model-combobox-option {
  width: 100%;
  min-height: 38px;
  display: block;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #eee;
  padding: 9px 10px;
  text-align: left;
  font: inherit;
  font-weight: 750;
  box-shadow: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-combobox-option:hover,
.model-combobox-option:focus {
  background: #1f1f1f;
  outline: none;
}

.model-combobox-option[aria-selected="true"] {
  background: rgba(255, 59, 48, .18);
  color: #fff;
  font-weight: 900;
}

#story-builder-static .static-field.required > span::before,
#story-builder-static .static-label.required::before {
  content: "* ";
  color: #ff3838;
  font-weight: 900;
}

#story-builder-static .static-field.required label::before,
#story-builder-static .static-field.required > label::before,
#story-builder-static .static-token label::before {
  content: none !important;
}

#story-builder-static .static-field.required,
#story-builder-static .static-label.required {
  position: relative;
}

#story-builder-static .static-unsafe-toggle {
  width: max-content;
  min-height: 42px;
  margin: 18px 0 8px;
  padding: 8px 14px;
}

#story-builder-static .static-unsafe-toggle input,
#story-builder-static .static-info-toggle input,
#story-builder-static .static-checkbox input {
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
}

#story-builder-static .static-unsafe-warning {
  margin: 0 0 18px !important;
  color: #ffb0b0 !important;
  border-color: rgba(255, 73, 73, .48) !important;
  background: rgba(255, 57, 57, .12) !important;
}

#story-builder-static .static-prologue-field {
  margin-bottom: 18px !important;
}

#story-builder-static .static-prologue-image-actions {
  margin: 8px 0 10px;
}

#story-builder-static .preview-dialogue-line {
  font-weight: 800 !important;
}

#story-builder-static .static-field-help {
  color: #9ca3af;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
}

#story-builder-static .static-info-panel {
  margin-top: 8px !important;
}

#story-builder-static .static-info-box {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

#story-builder-static .static-info-toggle {
  width: auto !important;
  min-height: 40px !important;
  padding: 8px 12px !important;
  white-space: nowrap;
}

#story-builder-static .builder-info-advanced.hidden,
#static-preview-info-card.hidden {
  display: none !important;
}

#story-builder-static .builder-info-advanced {
  margin-top: 14px;
}

#story-builder-static .builder-info-toolbar,
#story-builder-static .builder-info-insert-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

#story-builder-static .builder-info-toolbar select,
#story-builder-static .builder-info-toolbar button,
#story-builder-static .builder-info-insert-row button {
  min-height: 34px;
  border: 1px solid #343434;
  border-radius: 8px;
  background: #050505;
  color: #fff;
  padding: 0 10px;
  font-weight: 800;
}

#story-builder-static .builder-info-editor {
  min-height: 100px !important;
  height: 112px !important;
  resize: vertical !important;
}

#story-builder-static .static-summary-input {
  min-width: 280px !important;
}

#story-builder-static .static-summary-token {
  width: 88px !important;
  min-width: 88px !important;
  text-align: center !important;
}

#story-builder-static .static-character-card[data-nsfw="false"] .static-nsfw-fields,
#story-builder-static .static-nsfw-fields.hidden {
  display: none !important;
}

#story-builder-static .static-character-name {
  overflow-wrap: anywhere;
  display: inline-flex !important;
  align-items: center !important;
  min-height: 40px !important;
}

#story-builder-static .static-grid-3 {
  grid-template-columns: minmax(220px, 1fr) minmax(140px, 220px) !important;
}

#story-builder-static .static-token {
  grid-template-columns: minmax(0, 1fr) max-content 92px auto !important;
  align-items: center !important;
}

#story-builder-static .static-token .static-token-input,
#story-builder-static .static-grid-3 .static-token-input,
#story-builder-static input[data-builder-field="maxTokens"] {
  width: 100% !important;
  height: 46px !important;
  min-height: 46px !important;
  max-height: 46px !important;
  padding: 0 12px !important;
  text-align: center !important;
  line-height: 46px !important;
}

#story-builder-static .static-grid-3 .static-field {
  justify-content: end;
}

#story-builder-static .static-grid-3 .static-field select,
#story-builder-static .static-grid-3 .static-field input {
  height: 46px !important;
  min-height: 46px !important;
}

#story-builder-static .static-profile-line {
  align-items: end !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
}

#story-builder-static .static-profile-line .static-button {
  height: 46px !important;
  min-height: 46px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin-bottom: 0 !important;
}

#story-builder-static .static-profile-line select {
  height: 46px !important;
}

#story-builder-static .static-profile-panel {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: end !important;
  gap: 10px !important;
  margin-top: 12px !important;
  padding-top: 16px !important;
}

#story-builder-static .static-profile-panel label {
  display: grid !important;
  gap: 8px !important;
  margin: 0 !important;
}

#story-builder-static .static-profile-panel select,
#story-builder-static .static-profile-panel button {
  height: 46px !important;
  min-height: 46px !important;
  max-height: 46px !important;
  margin: 0 !important;
}

#story-builder-static .static-profile-panel button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  align-self: end !important;
  padding: 0 18px !important;
  white-space: nowrap !important;
}

#story-builder-static .static-character-head {
  align-items: center !important;
  gap: 12px !important;
}

#story-builder-static .static-character-toolbar {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  flex-wrap: wrap !important;
}

#story-builder-static .static-character-toolbar .static-button,
#story-builder-static .static-color-control {
  height: 40px !important;
  min-height: 40px !important;
}

#story-builder-static .static-character-toolbar .static-button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 14px !important;
}

#story-builder-static .static-color-control {
  display: inline-flex !important;
  align-items: center !important;
  align-self: center !important;
  gap: 8px !important;
  border: 1px solid #353535 !important;
  background: #171717 !important;
  border-radius: 8px !important;
  padding: 0 10px !important;
  font-weight: 800 !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
}

#story-builder-static .static-color-control input[type="color"] {
  width: 28px !important;
  min-width: 28px !important;
  height: 28px !important;
  min-height: 28px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 5px !important;
}

#story-builder-static .static-character-text-block {
  display: grid !important;
  gap: 10px !important;
  margin-top: 18px !important;
}

#story-builder-static .static-character-text-head {
  display: grid !important;
  grid-template-columns: 72px minmax(0, 1fr) !important;
  gap: 10px !important;
  align-items: center !important;
}

#story-builder-static .static-character-text-label {
  font-size: 14px !important;
  font-weight: 900 !important;
  color: #fff !important;
}

#story-builder-static .static-character-token-controls {
  display: grid !important;
  grid-template-columns: minmax(180px, 1fr) max-content 88px auto !important;
  gap: 10px !important;
  align-items: center !important;
}

#story-builder-static .static-character-token-controls .static-summary-input,
#story-builder-static .static-character-token-controls .static-summary-token,
#story-builder-static .static-character-token-controls .static-button {
  height: 40px !important;
  min-height: 40px !important;
}

#story-builder-static .static-character-token-controls .static-summary-input {
  width: 100% !important;
  min-width: 0 !important;
}

#story-builder-static .static-character-token-controls .static-summary-token {
  width: 88px !important;
  min-width: 88px !important;
  text-align: center !important;
  padding: 0 10px !important;
}

#story-builder-static .static-character-token-controls .static-button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 14px !important;
}

#story-builder-static .static-character-text-block textarea,
#story-builder-static .static-character-card textarea {
  width: 100% !important;
  box-sizing: border-box !important;
  border: 1px solid #363636 !important;
  background: #020202 !important;
  color: #fff !important;
  border-radius: 8px !important;
  padding: 12px 14px !important;
  min-height: 96px !important;
}

.static-draft-modal.hidden {
  display: none !important;
}

.static-draft-modal {
  position: fixed;
  inset: 0;
  z-index: 30000;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .86) !important;
  backdrop-filter: blur(2px);
  padding: 24px;
  box-sizing: border-box;
}

.static-draft-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .86);
}

.static-draft-dialog,
.static-draft-modal .modal-card,
.static-draft-panel {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 48px));
  overflow: auto;
  border: 1px solid #383838;
  border-radius: 8px;
  background: #101010 !important;
  color: #fff;
  padding: 18px;
  box-shadow: 0 24px 90px rgba(0, 0, 0, .82);
}

.static-draft-head,
.static-draft-item,
.static-draft-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.static-draft-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.static-draft-list {
  display: grid;
  gap: 8px;
}

.static-draft-item {
  justify-content: space-between;
  border: 1px solid #2f2f2f;
  border-radius: 8px;
  padding: 12px;
  background: #080808;
}

.static-draft-item strong,
.static-draft-item span {
  display: block;
}

.static-draft-item span {
  margin-top: 4px;
  color: #aaa;
  font-size: 12px;
}

.static-draft-actions button,
.static-draft-head button {
  min-height: 34px;
  border: 1px solid #383838;
  border-radius: 8px;
  background: #171717;
  color: #fff;
  padding: 0 12px;
  font-weight: 800;
}

.static-draft-actions .danger {
  border-color: #803030;
  color: #ff9c9c;
  background: #351010;
}

@media (max-width: 980px) {
  .builder-character-line-head {
    grid-template-columns: 1fr 1fr !important;
  }

  .builder-preview-restored-layout {
    grid-template-columns: 1fr !important;
  }

  .builder-preview-pane-restored {
    position: static !important;
    height: auto !important;
    border-left: 0 !important;
    border-top: 1px solid #333 !important;
  }
}

@media (max-width: 760px) {
  .builder-character-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .builder-character-line-head {
    grid-template-columns: 1fr !important;
  }

  #story-builder-static .static-grid-3 {
    grid-template-columns: 1fr !important;
  }
}

/* v0.41.0 final builder alignment overrides */
#story-builder-static .static-ai-field-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: center !important;
  gap: 12px !important;
  margin: 18px 0 8px !important;
}

#story-builder-static .static-ai-field-row > label,
#story-builder-static .static-prologue-label {
  margin: 0 !important;
  min-height: 40px !important;
  display: flex !important;
  align-items: center !important;
  font-weight: 900 !important;
}

#story-builder-static .static-ai-controls {
  display: grid !important;
  grid-template-columns: max-content 96px auto !important;
  align-items: center !important;
  gap: 8px !important;
  justify-content: end !important;
}

#story-builder-static .static-ai-controls .static-token-input,
#story-builder-static .static-ai-controls button {
  height: 42px !important;
  min-height: 42px !important;
  max-height: 42px !important;
  box-sizing: border-box !important;
}

#story-builder-static .static-ai-controls .static-token-input {
  width: 96px !important;
  text-align: center !important;
}

#story-builder-static .static-ai-controls button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 16px !important;
}

#story-builder-static .static-prologue-label {
  order: initial !important;
  margin: 20px 0 8px !important;
  min-height: 24px !important;
}

#story-builder-static .static-prologue-image-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin: 0 0 8px !important;
}

#story-builder-static .static-prologue-toolbar {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  grid-template-areas:
    "label label"
    "images controls" !important;
  align-items: center !important;
  gap: 10px !important;
  margin: 20px 0 10px !important;
}

#story-builder-static .static-prologue-toolbar .static-prologue-label {
  grid-area: label !important;
  margin: 0 !important;
}

#story-builder-static .static-prologue-toolbar .static-prologue-image-actions {
  grid-area: images !important;
  margin: 0 !important;
  justify-content: flex-start !important;
}

#story-builder-static .static-prologue-toolbar .static-ai-controls {
  grid-area: controls !important;
  justify-content: flex-end !important;
}

#story-builder-static .static-prologue-toolbar .static-prologue-image-actions button,
#story-builder-static .static-prologue-toolbar .static-ai-controls input,
#story-builder-static .static-prologue-toolbar .static-ai-controls button {
  height: 42px !important;
  min-height: 42px !important;
  max-height: 42px !important;
  box-sizing: border-box !important;
}

#story-builder-static .static-prologue-toolbar .static-ai-controls input {
  width: 96px !important;
  text-align: center !important;
}

@media (max-width: 760px) {
  #story-builder-static .static-prologue-toolbar {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "label"
      "images"
      "controls" !important;
    align-items: stretch !important;
  }
  #story-builder-static .static-prologue-toolbar .static-ai-controls,
  #story-builder-static .static-prologue-toolbar .static-prologue-image-actions {
    justify-content: flex-start !important;
  }
}

/* v0.43.0 prologue toolbar and character prologue controls */
#story-builder-static .static-prologue-appear {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 12px !important;
  border: 1px solid #353535 !important;
  border-radius: 8px !important;
  background: #171717 !important;
  color: #fff !important;
  font-weight: 800 !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
}

#story-builder-static .static-prologue-appear input {
  width: 14px !important;
  min-width: 14px !important;
  height: 14px !important;
}

#story-builder-static .static-prologue-toolbar {
  display: grid !important;
  grid-template-columns: auto minmax(24px, 1fr) auto !important;
  grid-template-areas: "images spacer controls" !important;
  align-items: center !important;
  gap: 10px !important;
  margin: 8px 0 10px !important;
}

#story-builder-static .static-prologue-label {
  display: block !important;
  margin: 0 0 10px !important;
}

#story-builder-static .static-prologue-toolbar .static-prologue-image-actions {
  grid-area: images !important;
  justify-self: start !important;
  margin: 0 !important;
  align-self: center !important;
}

#story-builder-static .static-prologue-toolbar .static-ai-controls,
#story-builder-static .static-prologue-toolbar .static-prologue-token-row {
  grid-area: controls !important;
  justify-self: end !important;
  margin: 0 !important;
  align-self: center !important;
}

#story-builder-static .static-prologue-token-row {
  display: grid !important;
  grid-template-columns: max-content 96px auto !important;
  gap: 8px !important;
  align-items: center !important;
}

#story-builder-static .static-preview-title {
  margin: 0 0 12px !important;
  font-size: 18px !important;
  font-weight: 900 !important;
  color: #fff !important;
}

@media (max-width: 760px) {
  #story-builder-static .static-prologue-toolbar {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "images"
      "controls" !important;
  }

  #story-builder-static .static-prologue-toolbar .static-ai-controls,
  #story-builder-static .static-prologue-toolbar .static-prologue-token-row {
    justify-self: start !important;
  }
}

#story-builder-static .static-profile-line,
#story-builder-static .static-profile-panel {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto !important;
  align-items: end !important;
  gap: 10px !important;
}

#story-builder-static .static-profile-line select,
#story-builder-static .static-profile-panel select,
#story-builder-static .static-profile-line button,
#story-builder-static .static-profile-panel button {
  height: 46px !important;
  min-height: 46px !important;
  max-height: 46px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
}

#story-builder-static .static-profile-line > label,
#story-builder-static .static-profile-panel > label {
  display: grid !important;
  grid-template-rows: auto 46px !important;
  gap: 8px !important;
  margin: 0 !important;
}

#story-builder-static .static-profile-line > button,
#story-builder-static .static-profile-panel > button {
  align-self: end !important;
}

#story-builder-static .static-character-head {
  display: grid !important;
  grid-template-columns: minmax(120px, 1fr) auto !important;
  align-items: center !important;
  gap: 12px !important;
}

#story-builder-static .static-character-toolbar {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  flex-wrap: nowrap !important;
}

#story-builder-static .static-character-toolbar .static-button,
#story-builder-static .static-character-toolbar button,
#story-builder-static .static-color-control,
#story-builder-static .static-character-toolbar .static-prologue-appear {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 42px !important;
  min-height: 42px !important;
  max-height: 42px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
}

#story-builder-static .static-character-toolbar .static-prologue-appear input {
  margin: 0 !important;
}

/* v0.49.1 compact builder section rhythm */
#story-builder-static .static-story-intro-row input,
#story-builder-static .static-prologue-token-row input,
#story-builder-static .static-prologue-toolbar .static-ai-controls input {
  width: 96px !important;
  max-width: 96px !important;
  flex: 0 0 96px !important;
  text-align: center !important;
}

#story-builder-static .static-prologue-label {
  margin: 0 0 6px !important;
  min-height: 0 !important;
}

#story-builder-static .static-prologue-toolbar {
  margin: 0 0 8px !important;
  gap: 8px !important;
}

#story-builder-static .static-prologue-field {
  gap: 6px !important;
}
