:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #eef1f4;
  background: #0b0d10;
  font-synthesis: none;
  --bg: #0b0d10;
  --surface: #11151a;
  --surface-2: #151a20;
  --line: #232930;
  --line-strong: #343c45;
  --text: #eef1f4;
  --muted: #98a1ab;
  --muted-2: #68717b;
  --accent: #9bb0c4;
  --accent-soft: #18212a;
  --danger: #d59284;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}
button, input, textarea { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 0 28px 72px;
}

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: #d8e2eb;
  font-size: 13px;
  font-weight: 750;
}
.brand strong { display: block; font-size: 14px; font-weight: 650; }
.brand small { display: block; margin-top: 1px; color: var(--muted-2); font-size: 9px; letter-spacing: .14em; }

.tabs { display: flex; gap: 20px; height: 100%; }
.tab {
  position: relative;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.tab::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after { background: var(--accent); }

.view { display: none; padding-top: 52px; }
.view.active { display: block; }
.page-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 380px);
  gap: 48px;
  align-items: end;
  padding-bottom: 28px;
}
h1, h2, h3, h4, h5 { margin: 0; letter-spacing: -.025em; }
h1 { font-size: clamp(30px, 4vw, 44px); font-weight: 650; }
h2 { font-size: 28px; font-weight: 650; }
h3 { font-size: 21px; font-weight: 650; }
h4 { font-size: 16px; font-weight: 650; }
p { color: var(--muted); line-height: 1.62; }
.page-head p { margin: 0; font-size: 14px; }
.eyebrow {
  margin-bottom: 6px;
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.step-wrap { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.step-indicator {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}
.step-indicator::-webkit-scrollbar { display: none; }
.step-pill {
  position: relative;
  flex: 0 0 auto;
  padding: 11px 20px 11px 0;
  margin-right: 20px;
  color: var(--muted-2);
  font-size: 11px;
  white-space: nowrap;
}
.step-pill::after {
  content: '—';
  position: absolute;
  right: 0;
  color: #313840;
}
.step-pill:last-child::after { display: none; }
.step-pill.done { color: #8195a8; }
.step-pill.active { color: var(--text); font-weight: 650; }

.creator-layout {
  width: min(820px, 100%);
  margin-top: 44px;
}
.form-panel { min-width: 0; }

.section-title { margin-bottom: 28px; }
.section-title > span { display: none; }
.section-title h3 { font-size: 24px; }
.section-title p { max-width: 680px; margin: 8px 0 0; font-size: 14px; }
.subsection { margin-top: 30px; padding-top: 25px; border-top: 1px solid var(--line); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.field { display: grid; gap: 8px; color: var(--muted); font-size: 12px; }
.field.full { grid-column: 1 / -1; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d1115;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}
input:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, textarea:focus { border-color: #536574; background: #0f1419; }
textarea { resize: vertical; }
input[type="radio"], input[type="checkbox"] { width: auto; accent-color: #8399ae; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.inline-actions { justify-content: flex-start; border-top: 0; padding-top: 0; margin-top: 22px; }
.button {
  border: 1px solid #4d5d6b;
  border-radius: 7px;
  background: #27333e;
  color: #f1f4f6;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
}
.button:hover { background: #303d49; }
.button.secondary {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}
.button.secondary:hover { color: var(--text); background: #12171c; }
.button:disabled { opacity: .3; cursor: default; }

.picker-list { display: grid; border-top: 1px solid var(--line); }
.picker-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.picker-card.compact { cursor: pointer; }
.picker-card.compact:hover { background: #0e1216; }
.picker-card[hidden] { display: none; }
.picker-main p { max-width: 620px; margin: 6px 0 0; font-size: 13px; }
.picker-main small { color: var(--muted-2); font-size: 11px; }
.picker-main b { font-size: 14px; }
.picker-control { display: flex; align-items: center; gap: 18px; }
.check-row, .level-row { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.level-row input { width: 58px; padding: 7px; text-align: center; }
.level-row.disabled { opacity: .28; }
.link-button, .trait-title {
  border: 0;
  background: transparent;
  color: #e6ebef;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.link-button { display: block; margin-bottom: 4px; font-size: 16px; font-weight: 650; }
.link-button:hover, .trait-title:hover { color: #fff; }

.stats-editor { border-top: 1px solid var(--line); }
.stat-edit {
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 86px 46px;
  gap: 16px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.stat-edit span { color: #c8ced4; font-size: 11px; font-weight: 700; letter-spacing: .06em; }
.stat-edit input { padding: 7px; text-align: center; }
.stat-edit b { color: var(--accent); text-align: right; font-size: 13px; }

.summary-panel {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.summary-panel summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  cursor: pointer;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
}
.summary-panel summary::-webkit-details-marker { display: none; }
.summary-panel summary::after { content: '+'; color: var(--muted-2); margin-left: auto; }
.summary-panel[open] summary::after { content: '−'; }
.summary-panel summary strong { color: #dce2e7; font-weight: 600; }
.summary-panel #summary { padding: 4px 0 22px; }
.mini-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 10px 0 20px;
}
.mini-stats div { display: grid; gap: 2px; padding: 9px 10px; border-right: 1px solid var(--line); }
.mini-stats div:last-child { border-right: 0; }
.mini-stats span { color: var(--muted-2); font-size: 8px; font-weight: 750; letter-spacing: .07em; }
.mini-stats b { font-size: 16px; }
.mini-stats small { color: var(--accent); font-size: 10px; }
.summary-traits h4 { display: flex; justify-content: space-between; margin-bottom: 9px; font-size: 12px; }
.summary-traits h4 span { color: var(--muted-2); font-size: 10px; }
.chip {
  border: 0;
  border-bottom: 1px solid #39434d;
  background: transparent;
  color: #bcc9d4;
  padding: 4px 0;
  margin: 0 13px 5px 0;
  cursor: pointer;
  font-size: 11px;
}

.review-block { padding-top: 4px; }
.review-block > p { margin-top: 6px; }
.review-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 22px 0;
}
.review-stats span { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; padding: 10px 12px; border-right: 1px solid var(--line); }
.review-stats span:nth-child(3n) { border-right: 0; }
.review-stats b { color: var(--muted-2); font-size: 9px; }
.review-stats em { color: var(--accent); font-style: normal; }
.review-traits { color: #c8ced4; }
.muted { color: var(--muted-2); }
.error { padding: 13px 0; border-top: 1px solid #64433d; border-bottom: 1px solid #64433d; color: #dea69b; }

.codex-head { padding-bottom: 25px; }
.codex-toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.search { min-width: 0; flex: 1; border: 0; background: transparent; padding-left: 0; }
.search:hover, .search:focus { border: 0; background: transparent; }
.search.wide { margin-bottom: 8px; border: 1px solid var(--line); background: #0d1115; padding-left: 12px; }
.codex-meta { flex: 0 0 auto; color: var(--muted-2); font-size: 11px; }
.trait-grid { border-top: 0; }
.trait-card {
  display: grid;
  grid-template-columns: 150px minmax(180px, 260px) 1fr;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}
.trait-card-top { display: grid; gap: 4px; }
.category, .level-count { color: var(--muted-2); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.trait-title { font-size: 16px; font-weight: 650; }
.trait-card p { margin: 0; font-size: 13px; }
.trait-tags { display: none; }

.trait-dialog {
  width: min(720px, calc(100% - 28px));
  max-height: 88vh;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #101419;
  color: var(--text);
  padding: 28px;
  box-shadow: 0 28px 90px #000b;
}
.trait-dialog::backdrop { background: #050608db; backdrop-filter: blur(3px); }
.dialog-close { position: absolute; right: 14px; top: 10px; border: 0; background: transparent; color: var(--muted-2); font-size: 25px; cursor: pointer; }
.dialog-lead { font-size: 14px; }
.dialog-facts { display: flex; flex-wrap: wrap; gap: 15px; padding: 12px 0 20px; border-bottom: 1px solid var(--line); }
.dialog-facts span { color: var(--muted); font-size: 11px; }
.levels { margin-top: 20px; border-top: 1px solid var(--line); }
.levels > h3 { margin-bottom: 13px; }
.level-card { border-bottom: 1px solid var(--line); }
.level-card summary { list-style: none; display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; padding: 13px 0; cursor: pointer; }
.level-card summary::-webkit-details-marker { display: none; }
.level-card summary b { color: var(--accent); }
.level-card summary span { color: #d9dfe4; }
.level-body { padding: 3px 0 15px 48px; border-top: 1px dashed #252c33; font-size: 13px; }
.level-body p { color: var(--muted); }
.level-body h3, .level-body h4, .level-body h5 { margin: 14px 0 7px; font-size: 15px; }
.level-body ul { padding-left: 18px; }
.info-dot { width: 21px; height: 21px; border: 1px solid var(--line-strong); border-radius: 50%; background: transparent; color: var(--accent); cursor: help; }

.tooltip {
  position: fixed;
  z-index: 1000;
  width: 280px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: .12s ease;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #11161b;
  color: #d8dde2;
  padding: 9px 11px;
  box-shadow: 0 12px 34px #000a;
  font-size: 11px;
  line-height: 1.45;
}
.tooltip.visible { opacity: 1; transform: translateY(0); }
code { color: #bdcad5; }

@media (max-width: 760px) {
  .app-shell { padding-inline: 18px; }
  .topbar { height: 62px; }
  .brand strong { font-size: 12px; }
  .page-head { grid-template-columns: 1fr; gap: 12px; padding-bottom: 22px; }
  .view { padding-top: 36px; }
  .creator-layout { margin-top: 32px; }
  .field-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .picker-card { grid-template-columns: 1fr; gap: 12px; }
  .picker-control { justify-content: space-between; }
  .mini-stats { grid-template-columns: repeat(3, 1fr); }
  .mini-stats div:nth-child(3) { border-right: 0; }
  .mini-stats div:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .review-stats { grid-template-columns: 1fr 1fr; }
  .review-stats span:nth-child(3n) { border-right: 1px solid var(--line); }
  .review-stats span:nth-child(2n) { border-right: 0; }
  .trait-card { grid-template-columns: 1fr; gap: 7px; }
  .trait-card-top { display: flex; gap: 10px; }
}

@media (max-width: 480px) {
  .app-shell { padding-inline: 14px; }
  .brand-mark { display: none; }
  .tabs { gap: 14px; }
  .tab { font-size: 12px; }
  .step-pill { margin-right: 14px; padding-right: 14px; }
  .form-actions { justify-content: space-between; }
  .review-stats { grid-template-columns: 1fr; }
  .review-stats span { border-right: 0 !important; }
}
