/* ============================================================
   StoryForge Setup — Codex Identity
   ============================================================ */

/* --- Reset ------------------------------------------------ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Base ------------------------------------------------- */

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  min-height: 100dvh;
}

/* --- Page layout ------------------------------------------ */

.setup-page {
  min-height: 100dvh;
}

/* --- Top bar ----------------------------------------------- */

.setup-topbar {
  border-bottom: 0.5px solid var(--hairline);
  padding: 20px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setup-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setup-wordmark {
  font-family: var(--font-body);
  font-size: 20px;
  color: var(--gold);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .setup-wordmark:hover {
    color: var(--fg);
  }
}

.setup-back-link {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--fg-dim);
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: color 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .setup-back-link:hover {
    color: var(--gold);
  }
}

/* --- Surface ----------------------------------------------- */

.setup-surface {
  max-width: 620px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

/* --- Diamond anchor ornament ------------------------------ */

.setup-anchor {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 0 48px;
}

.setup-anchor-line {
  height: 0.5px;
  width: 80px;
  background: var(--fg-faint);
}

.setup-anchor-diamond {
  height: 5px;
  width: 5px;
  background: var(--gold);
  transform: rotate(45deg);
  flex-shrink: 0;
}

/* --- Masthead ---------------------------------------------- */

.setup-header {
  text-align: center;
  margin-bottom: 56px;
}

.setup-header-label {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--fg-label);
  margin-bottom: 12px;
}

.setup-title {
  font-family: var(--font-body);
  font-size: 32px;
  color: var(--fg);
  line-height: 1.2;
  margin: 0 0 10px;
  font-weight: 400;
}

.setup-subtitle {
  font-family: var(--font-body);
  font-size: 15px;
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.5;
  max-width: 440px;
  margin: 0 auto;
}

/* --- Form layout ------------------------------------------ */

.setup-form {
  display: flex;
  flex-direction: column;
}

.field {
  margin: 32px 0;
}

.field--section {
  margin: 0 0 24px;
}

/* --- Codex container (shared by all authoring sections) --- */

.codex-container {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--glass-radius);
  box-shadow: var(--glass-catchlight), var(--glass-shadow);
  padding: 36px 32px 28px;
  position: relative;
}

/* SF-VISUAL-01: signet-tick section label (reconciled to match account) */
.codex-container-label {
  position: static;
  transform: none;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  padding: 0;
  margin-bottom: 16px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--fg-label);
  white-space: nowrap;
}
.codex-container-label::before {
  content: "";
  width: 5px;
  height: 5px;
  background: var(--gold);
  transform: rotate(45deg);
  box-shadow: 0 0 6px rgba(201, 160, 85, 0.5);
  flex-shrink: 0;
}

.codex-container-hint {
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.5;
  margin: 0 0 20px;
}

/* --- Field label and hint --------------------------------- */

.field-label {
  display: block;
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--fg-label);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.field-hint {
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.5;
  margin: 0 0 12px;
}

/* --- Field input ------------------------------------------ */

.field-input {
  display: block;
  width: 100%;
  background: var(--container-bg);
  border: 0.5px solid var(--container-border);
  border-radius: 2px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.4;
  padding: 14px 16px;
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s;
}

.field-input::placeholder {
  color: var(--fg-dim);
  font-style: italic;
}

.field-input:focus {
  border-color: var(--container-border-active);
  background: var(--container-bg-active);
}

.field-input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Backstory textarea ----------------------------------- */

.field-textarea {
  resize: vertical;
  min-height: 160px;
  line-height: 1.6;
  font-style: italic;
  font-size: 16px;
}

/* --- Backstory helper ------------------------------------- */

.backstory-helper {
  padding: 18px 0 14px;
  margin-top: 20px;
  border-top: 0.5px solid var(--hairline);
}

.backstory-helper-label {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--fg-dim);
  margin-bottom: 10px;
}

.backstory-helper-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--fg-muted);
  line-height: 1.85;
}

.backstory-helper-list li {
  display: flex;
  align-items: start;
  gap: 10px;
  margin-bottom: 4px;
}

.backstory-helper-list li::before {
  content: "◆";
  color: var(--gold);
  font-size: 9px;
  flex-shrink: 0;
  padding-top: 5px;
}

.backstory-aging-note {
  font-family: var(--font-body);
  font-size: 13px;
  font-style: italic;
  color: var(--fg-dim);
  line-height: 1.55;
  padding-top: 14px;
  border-top: 0.5px solid rgba(201, 160, 85, 0.1);
  margin: 14px 0 0;
}

/* --- Realm container -------------------------------------- */

.realm-card {
  background: rgba(201, 160, 85, 0.07);
  border: 0.5px solid var(--gold);
  border-radius: 2px;
  padding: 20px 22px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.realm-card-name {
  font-family: var(--font-body);
  font-size: 20px;
  color: var(--gold);
}

.realm-card-status {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--gold);
}

.realm-footer {
  font-family: var(--font-body);
  font-size: 12px;
  font-style: italic;
  color: var(--fg-dim);
  text-align: center;
  margin: 0;
}

/* --- Genre container -------------------------------------- */

.genre-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.genre-chip {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  padding: 7px 16px;
  background: var(--inner-pill-bg);
  border: 0.5px solid var(--inner-pill-border);
  border-radius: 2px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--fg-dim);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

@media (hover: hover) and (pointer: fine) {
  .genre-chip:hover:not(.genre-chip--selected) {
    border-color: var(--container-border-active);
    color: var(--fg-muted);
  }
}

.genre-chip--selected {
  background: rgba(201, 160, 85, 0.08);
  border-color: var(--gold);
  color: var(--gold);
}

.genre-chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

.genre-chip[data-available="false"] {
  opacity: 0.5;
  cursor: default;
}

@media (hover: hover) and (pointer: fine) {
  .genre-chip[data-available="false"]:hover {
    border-color: var(--inner-pill-border);
    color: var(--fg-dim);
    background: var(--inner-pill-bg);
  }
}

.genre-description {
  background: rgba(201, 160, 85, 0.025);
  border: 0.5px solid var(--hairline);
  border-radius: 2px;
  padding: 16px 18px;
  margin-bottom: 18px;
  min-height: 64px;
}

.genre-description-text {
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.55;
  margin: 0;
}

.genre-footer {
  font-family: var(--font-body);
  font-size: 12px;
  font-style: italic;
  color: var(--fg-dim);
  text-align: center;
  margin: 0;
}

/* --- Ambitions -------------------------------------------- */

.ambition-section {
  margin-bottom: 28px;
}

.ambition-section:last-child {
  margin-bottom: 0;
}

.ambition-section-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.ambition-section-diamond {
  color: var(--gold);
  font-size: 11px;
  flex-shrink: 0;
}

.ambition-section-label {
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.3em;
  font-weight: 500;
  color: var(--gold);
}

.ambition-section-subhead {
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.5;
  margin: 0 0 12px 18px;
}

.ambition-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  margin-left: 18px;
}

.ambition-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 0.5px solid var(--container-border);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 8px 0 10px;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.ambition-input::placeholder {
  color: var(--fg-dim);
  font-style: italic;
}

.ambition-input:focus {
  border-bottom-color: var(--gold);
}

.ambition-input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 0;
}

.add-ambition {
  all: unset;
  font-family: var(--font-body);
  font-size: 13px;
  font-style: italic;
  color: var(--gold);
  cursor: pointer;
  margin-left: 18px;
  transition: color 0.12s;
}

@media (hover: hover) and (pointer: fine) {
  .add-ambition:hover {
    color: var(--fg);
  }
}

.add-ambition:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Traits ----------------------------------------------- */

.traits-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.trait-chip {
  all: unset;
  display: inline-block;
  box-sizing: border-box;
  padding: 6px 14px;
  background: var(--inner-pill-bg);
  border: 0.5px solid var(--inner-pill-border);
  border-radius: 2px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--fg-dim);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

@media (hover: hover) and (pointer: fine) {
  .trait-chip:hover:not(.is-selected) {
    border-color: var(--container-border-active);
    color: var(--fg-muted);
  }
}

.trait-chip.is-selected {
  background: rgba(201, 160, 85, 0.08);
  border-color: var(--gold);
  color: var(--gold);
}

.trait-chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

.traits-custom-row {
  padding-top: 18px;
  border-top: 0.5px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 10px;
}

.traits-custom-input {
  flex: 1;
  min-width: 0;
  background: var(--container-bg);
  border: 0.5px solid var(--container-border);
  border-radius: 2px;
  padding: 10px 14px;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s;
}

.traits-custom-input::placeholder {
  color: var(--fg-dim);
  font-style: italic;
}

.traits-custom-input:focus {
  border-color: var(--container-border-active);
  background: var(--container-bg-active);
}

.traits-custom-input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Opening situation cards ------------------------------ */

.situation-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.situation-card {
  background: var(--container-bg);
  border: 0.5px solid var(--container-border);
  border-radius: 2px;
  padding: 18px 20px;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--fg-muted);
  line-height: 1.45;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

@media (hover: hover) and (pointer: fine) {
  .situation-card:hover:not(.is-selected) {
    border-color: var(--container-border-active);
    color: var(--fg);
  }
}

.situation-card:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.situation-card.is-selected {
  background: rgba(201, 160, 85, 0.07);
  border-color: var(--gold);
  color: var(--fg);
}

.situation-card--custom {
  color: var(--fg-dim);
  font-style: italic;
  font-size: 15px;
}

.situation-card--custom.is-selected {
  color: var(--fg-muted);
}

#situationCustom {
  margin-top: 10px;
}

/* --- Form error ------------------------------------------- */

.form-error {
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  color: var(--fg-muted);
  margin: 16px 0 0;
  text-align: center;
}

.form-error[hidden] {
  display: none;
}

/* --- Submit ----------------------------------------------- */

.setup-submit {
  text-align: center;
  margin-top: 40px;
}

.begin-btn {
  all: unset;
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--gold);
  color: var(--bg);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.08em;
  border-radius: 2px;
  cursor: pointer;
  text-align: center;
  box-sizing: border-box;
  transition: filter 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .begin-btn:hover {
    filter: brightness(1.1);
  }
}

.begin-btn:disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

.begin-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Forge moment ----------------------------------------- */

.forge-moment {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.75rem;
  margin-top: 0.5rem;
}

.forge-moment[hidden] {
  display: none;
}

@keyframes forge-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.forge-phrase {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.5;
  text-align: center;
  animation: forge-fade-in 0.8s ease-out both;
}

.forge-phrase--saga {
  font-size: 19px;
}

.forge-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.forge-dot {
  width: 5px;
  height: 5px;
  background: var(--gold);
  transform: rotate(45deg);
  border-radius: 0;
  opacity: 0.4;
  animation: forge-pulse 1.4s ease-in-out infinite;
}

.forge-dot:nth-child(2) { animation-delay: 0.2s; }
.forge-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes forge-pulse {
  0%, 100% { opacity: 0.3; }
  50%       { opacity: 1; }
}

#enterSagaBtn {
  animation: forge-fade-in 0.6s ease-out both;
}

#enterSagaBtn[hidden] {
  display: none;
}

/* --- Progress bar (sticky, 7 segments) -------------------- */

.setup-progress {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  gap: 3px;
  padding: 0;
  background: var(--bg);
  border-bottom: 0.5px solid var(--hairline);
}

.setup-progress-segment {
  flex: 1;
  height: 3px;
  background: rgba(201, 160, 85, 0.12);
  transition: background 0.25s;
}

.setup-progress-segment.is-filled {
  background: var(--gold);
}

/* --- Realm chip grid -------------------------------------- */

.realm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.realm-chip {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-sizing: border-box;
  padding: 7px 16px;
  background: var(--inner-pill-bg);
  border: 0.5px solid var(--inner-pill-border);
  border-radius: 2px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--fg-dim);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

@media (hover: hover) and (pointer: fine) {
  .realm-chip:hover:not(.realm-chip--selected) {
    border-color: var(--container-border-active);
    color: var(--fg-muted);
  }
}

.realm-chip--selected {
  background: rgba(201, 160, 85, 0.08);
  border-color: var(--gold);
  color: var(--gold);
}

.realm-chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- PREVIEW badge (realm + genre chips) ------------------ */

.chip-preview-badge {
  font-family: var(--font-ui);
  font-size: 9px;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--fg-dim);
  background: rgba(201, 160, 85, 0.06);
  border: 0.5px solid rgba(201, 160, 85, 0.18);
  border-radius: 2px;
  padding: 1px 5px;
  vertical-align: middle;
  pointer-events: none;
}

/* --- Chip description (shared realm + genre) -------------- */

.chip-description {
  background: rgba(201, 160, 85, 0.025);
  border: 0.5px solid var(--hairline);
  border-radius: 2px;
  padding: 14px 16px;
  margin-bottom: 14px;
  min-height: 52px;
}

.chip-description-text {
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.55;
  margin: 0;
}

/* --- Traits custom Add button ----------------------------- */

.traits-add-btn {
  all: unset;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--gold);
  border: 0.5px solid rgba(201, 160, 85, 0.4);
  border-radius: 2px;
  padding: 6px 14px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  box-sizing: border-box;
  transition: color 0.12s, border-color 0.12s;
}

@media (hover: hover) and (pointer: fine) {
  .traits-add-btn:hover {
    color: #D4AA60;
    border-color: rgba(201, 160, 85, 0.7);
  }
}

.traits-add-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Ambitions guidance + badges -------------------------- */

.ambitions-guidance {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14px;
  color: var(--fg-muted);
  line-height: 1.5;
  margin: 0 0 24px;
}

.ambition-badge {
  font-family: var(--font-ui);
  font-size: 9px;
  letter-spacing: 0.1em;
  font-weight: 600;
  border-radius: 2px;
  padding: 1px 6px;
  vertical-align: middle;
}

.ambition-badge--required {
  color: var(--gold);
  background: rgba(201, 160, 85, 0.1);
  border: 0.5px solid rgba(201, 160, 85, 0.3);
}

.ambition-optional {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 12px;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--fg-dim);
}

/* --- Backstory intro line --------------------------------- */

.backstory-intro {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 16px;
}

.backstory-intro-diamond {
  color: var(--gold);
  font-size: 10px;
  flex-shrink: 0;
}

.backstory-intro-text {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14px;
  color: var(--fg-muted);
  line-height: 1.5;
}

/* --- Realm Helper bar ------------------------------------- */

.realm-helper-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  margin-bottom: 10px;
}

.realm-helper-btn {
  all: unset;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--gold);
  border: 0.5px solid rgba(201, 160, 85, 0.4);
  border-radius: 2px;
  padding: 7px 16px;
  cursor: pointer;
  box-sizing: border-box;
  transition: color 0.12s, border-color 0.12s;
}

@media (hover: hover) and (pointer: fine) {
  .realm-helper-btn:hover:not(:disabled) {
    color: #D4AA60;
    border-color: rgba(201, 160, 85, 0.7);
  }
}

.realm-helper-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.realm-helper-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

.realm-helper-budget {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.05em;
}

.realm-helper-response {
  background: rgba(201, 160, 85, 0.04);
  border: 0.5px solid rgba(201, 160, 85, 0.18);
  border-radius: 2px;
  padding: 14px 16px;
  margin-bottom: 16px;
}

.realm-helper-response[hidden] {
  display: none;
}

.realm-helper-response-text {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14px;
  color: var(--fg-muted);
  line-height: 1.6;
}

/* --- Opening recommended ---------------------------------- */

.opening-recommended {
  margin-bottom: 20px;
}

.opening-recommended[hidden] {
  display: none;
}

.opening-recommended-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.opening-recommended-label {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--gold);
  text-transform: uppercase;
}

.opening-refresh-btn {
  all: unset;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--fg-dim);
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: color 0.12s;
}

@media (hover: hover) and (pointer: fine) {
  .opening-refresh-btn:hover:not(:disabled) {
    color: var(--gold);
  }
}

.opening-refresh-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.opening-refresh-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

.opening-helper-loading {
  padding: 12px 0 6px;
}

.opening-helper-loading[hidden] {
  display: none;
}

.opening-helper-loading-text {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14px;
  color: var(--fg-dim);
}

.opening-recommended-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.opening-recommended-card {
  background: rgba(201, 160, 85, 0.04);
  border: 0.5px solid rgba(201, 160, 85, 0.15);
  border-radius: 2px;
  padding: 16px 18px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--fg-muted);
  line-height: 1.45;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

@media (hover: hover) and (pointer: fine) {
  .opening-recommended-card:hover:not(.is-selected) {
    border-color: var(--container-border-active);
    color: var(--fg);
  }
}

.opening-recommended-card:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.opening-recommended-card.is-selected {
  background: rgba(201, 160, 85, 0.07);
  border-color: var(--gold);
  color: var(--fg);
}

/* --- Classic opening header ------------------------------- */

.opening-classic-header {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--fg-dim);
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* --- Summary card ----------------------------------------- */

.setup-summary {
  background: var(--container-bg-active);
  border: 0.5px solid var(--container-border-active);
  border-radius: 2px;
  padding: 24px 28px;
  margin-top: 40px;
}

.setup-summary-label {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--fg-dim);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.setup-summary-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 20px;
  margin-bottom: 24px;
}

.setup-summary-list dt {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--fg-dim);
  text-transform: uppercase;
  align-self: start;
  padding-top: 1px;
}

.setup-summary-list dd {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--fg);
  margin: 0;
  line-height: 1.4;
}

/* --- Lore disclosure modal -------------------------------- */

.lore-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 13, 10, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
}

.lore-modal-overlay[hidden] {
  display: none;
}

.lore-modal-box {
  background: #1A1610;
  border: 0.5px solid rgba(201, 160, 85, 0.3);
  border-radius: 2px;
  padding: 36px 32px 28px;
  max-width: 420px;
  width: 100%;
}

.lore-modal-title {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--fg-dim);
  text-transform: uppercase;
  margin-bottom: 20px;
}

.lore-modal-body {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--fg-muted);
  line-height: 1.6;
  margin-bottom: 14px;
}

.lore-modal-body:last-of-type {
  margin-bottom: 28px;
}

.lore-modal-actions {
  display: flex;
  gap: 12px;
}

.lore-modal-back {
  all: unset;
  flex: 1;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--fg-dim);
  border: 0.5px solid rgba(201, 160, 85, 0.15);
  border-radius: 2px;
  padding: 13px 16px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  min-height: 44px;
  box-sizing: border-box;
}

@media (hover: hover) and (pointer: fine) {
  .lore-modal-back:hover {
    color: var(--fg);
    border-color: rgba(201, 160, 85, 0.25);
  }
}

.lore-modal-back:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

.lore-modal-continue {
  all: unset;
  flex: 2;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.05em;
  font-weight: 500;
  background: var(--gold);
  color: var(--bg);
  border-radius: 2px;
  padding: 13px 16px;
  cursor: pointer;
  transition: filter 0.15s;
  min-height: 44px;
  box-sizing: border-box;
}

@media (hover: hover) and (pointer: fine) {
  .lore-modal-continue:hover {
    filter: brightness(1.1);
  }
}

.lore-modal-continue:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Responsive ------------------------------------------- */

@media (max-width: 600px) {
  .setup-topbar {
    padding: 16px 20px;
  }

  .setup-wordmark {
    font-size: 18px;
  }

  .setup-surface {
    padding: 32px 20px 64px;
  }

  .setup-anchor {
    padding-bottom: 32px;
  }

  .setup-anchor-line {
    width: 60px;
  }

  .setup-header {
    margin-bottom: 40px;
  }

  .setup-title {
    font-size: 26px;
  }

  .setup-subtitle {
    font-size: 14px;
  }

  .codex-container {
    padding: 32px 24px 24px;
  }

  .setup-summary {
    background: var(--bg);
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
    margin-top: 24px;
    padding: 20px 20px 32px;
  }

}

/* --- Hard Limits ------------------------------------------ */

.hard-limits-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.hard-limit-chip {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-sizing: border-box;
  padding: 6px 14px;
  background: var(--inner-pill-bg);
  border: 0.5px solid var(--inner-pill-border);
  border-radius: 2px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--fg-dim);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

@media (hover: hover) and (pointer: fine) {
  .hard-limit-chip:hover:not(.is-selected) {
    border-color: var(--container-border-active);
    color: var(--fg-muted);
  }
}

.hard-limit-chip.is-selected {
  background: rgba(201, 160, 85, 0.08);
  border-color: var(--gold);
  color: var(--gold);
}

.hard-limit-chip:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 2px;
}

.hl-info-icon {
  font-size: 11px;
  opacity: 0.45;
  pointer-events: none;
}

.hard-limit-description {
  background: rgba(201, 160, 85, 0.025);
  border: 0.5px solid var(--hairline);
  border-radius: 2px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.hard-limit-description[hidden] {
  display: none;
}

.hard-limit-description-text {
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.5;
  margin: 0;
}

.hard-limits-ar-notice {
  background: rgba(201, 160, 85, 0.05);
  border: 0.5px solid rgba(201, 160, 85, 0.22);
  border-radius: 2px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

.hard-limits-ar-notice[hidden] {
  display: none;
}

.hard-limits-ar-notice-text {
  font-family: var(--font-body);
  font-size: 13px;
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.4;
  margin: 0;
}

.hard-limits-no-limits {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  border-top: 0.5px solid var(--hairline);
  cursor: pointer;
  margin-top: 4px;
}

.hard-limits-no-limits input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 0.5px solid var(--container-border-active);
  border-radius: 2px;
  background: var(--container-bg);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color 0.12s, background 0.12s;
}

.hard-limits-no-limits input[type="checkbox"]:checked {
  background: var(--gold);
  border-color: var(--gold);
}

.hard-limits-no-limits input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 1px;
  width: 5px;
  height: 8px;
  border: 1.5px solid var(--bg);
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.hard-limits-no-limits span {
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.3;
}

/* --- Inline birthdate gate --------------------------------- */

.setup-birthdate-gate {
  margin-top: 16px;
}

.setup-birthdate-gate[hidden] {
  display: none;
}

.setup-birthdate-gate-prompt {
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  color: var(--fg-muted);
  line-height: 1.5;
  margin: 0 0 14px;
  text-align: center;
}

.setup-birthdate-gate-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.setup-gate-cancel {
  all: unset;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 10px 16px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  letter-spacing: 0.03em;
}

.setup-gate-cancel:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

.char-counter {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--fg-muted);
  text-align: right;
  margin-top: 4px;
}

/* Per-input live counter on each ambition row (short-term, long-term, avoid).
   Sits directly beneath its input inside the flex column. Tone shifts as the
   value nears (gold) and exceeds (warm red) the 200-character server cap. */
.ambition-counter {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--fg-muted);
  text-align: right;
  margin-top: -4px;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}

.ambition-counter.is-near {
  color: var(--gold);
}

.ambition-counter.is-over {
  color: #E0735C;
  font-weight: 600;
}

@media (max-width: 479px) {
  .lore-modal-box {
    padding: 28px 20px 24px;
  }

  .lore-modal-actions {
    flex-direction: column-reverse;
  }
}

/* SF-VISUAL-01 carry-through (presentation-only; reversible) */
.begin-btn, .lore-modal-continue {
  background: var(--lit-metal); color: var(--bg);
  border-radius: var(--btn-radius); box-shadow: var(--lit-metal-sheen);
}
@media (hover: hover) and (pointer: fine) {
  .begin-btn:hover,
  .lore-modal-continue:hover { background: var(--lit-metal); filter: brightness(1.06); }
}

/* Shared character counter (window.CharCounter). Same treatment the synopsis
   box uses; generalised here because five creator fields now share it. */
.char-count {
  margin: 0.375rem 0 0;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--fg-label);
  text-align: right;
}

.char-count.is-over { color: var(--gold); }
