:root {
  --bg-deep: #0a0b12;
  --bg-card: rgba(18, 20, 32, 0.82);
  --bg-elevated: rgba(28, 32, 50, 0.9);
  --bg-select: #1e1832;
  --bg-select-option: #2a2240;
  --border: rgba(148, 163, 184, 0.14);
  --text: #e8eaf4;
  --text-muted: #94a3b8;
  --accent: #a78bfa;
  --accent-glow: rgba(167, 139, 250, 0.35);
  --accent-2: #22d3ee;
  --accent-2-glow: rgba(34, 211, 238, 0.2);
  --dot-empty: #2f3541;
  --dot-fill: #c9a24d;
  --dot-locked-fill-opacity: 0.88;
  --dot-locked-fill-border: #b89a55;
  --dot-locked-fill-bg: radial-gradient(circle at 30% 25%, #e8d6a8, rgba(120, 92, 40, 0.9));
  --dot-locked-fill-filter: brightness(0.95);
  --danger: #f87171;
  --success: #4ade80;
  --radius: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --font-display: "Cinzel", Georgia, serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg-deep);
  line-height: 1.6;
}

.aurora {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 15% 10%, rgba(124, 58, 237, 0.18), transparent 60%),
    radial-gradient(ellipse 50% 40% at 85% 20%, rgba(34, 211, 238, 0.1), transparent 55%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(79, 70, 229, 0.12), transparent 60%);
  z-index: 0;
}

.site-header,
.container,
.site-footer {
  position: relative;
  z-index: 1;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  background: rgba(10, 11, 18, 0.7);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  color: var(--accent);
  font-size: 1.4rem;
  text-shadow: 0 0 20px var(--accent-glow);
}

.brand-text {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.brand-text em {
  color: var(--accent-2);
  font-style: normal;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-header nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-header nav a:hover {
  color: var(--text);
}

.container {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.site-footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.25;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: white;
  box-shadow: 0 8px 30px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2rem;
  align-items: start;
  margin-bottom: 3rem;
}

.eyebrow {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0 0 1rem;
}

.lead {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 52ch;
}

.hero-actions {
  margin-top: 1.75rem;
}

.hero-card,
.feature-card,
.info-card,
.preview-panel,
.wizard-main {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-card {
  padding: 1.5rem;
}

.steps-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-muted);
}

.steps-list li {
  margin-bottom: 0.65rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
}

.feature-card {
  padding: 1.5rem;
}

.feature-card h3 {
  margin-top: 0;
  color: var(--accent);
}

.feature-card p {
  color: var(--text-muted);
  margin-bottom: 0;
}

.wizard-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.wizard-sidebar {
  position: sticky;
  top: 1rem;
}

.wizard-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.wizard-step {
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  cursor: pointer;
}

.wizard-step.active {
  background: rgba(124, 58, 237, 0.18);
  border-color: rgba(167, 139, 250, 0.35);
  color: var(--text);
}

.wizard-step.done {
  color: var(--success);
}

.preview-panel {
  padding: 1rem;
}

.preview-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.preview-content {
  font-size: 0.85rem;
  line-height: 1.5;
}

.preview-content .stat-line {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.wizard-main {
  padding: 1.75rem;
}

.wizard-panel {
  display: none;
}

.wizard-panel.active {
  display: block;
}

.panel-intro {
  color: var(--text-muted);
  margin-top: -0.25rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.field input,
.field textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
}

select {
  color-scheme: dark;
  background-color: var(--bg-select);
  color: var(--text);
  border: 1px solid rgba(167, 139, 250, 0.22);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  font: inherit;
}

select option {
  background-color: var(--bg-select-option);
  color: var(--text);
}

select option:checked {
  background-color: #3d2f5c;
  color: #f3efff;
}

.field select {
  width: 100%;
  cursor: pointer;
}

.field input:focus,
.field textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(167, 139, 250, 0.55);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
}

.hint,
.hint-inline {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.hint-inline {
  font-weight: 400;
}

.info-card {
  padding: 1rem;
  margin: 1rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.path-block {
  margin-bottom: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.15);
}

.path-block h4,
.path-block h5 {
  margin: 0.75rem 0 0.5rem;
  color: var(--accent-2);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.path-block-header h4 {
  margin-top: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--accent);
}

.path-meta {
  margin: 0.5rem 0 1rem;
  font-size: 0.85rem;
}

.arena-section {
  margin-bottom: 0.75rem;
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.skill-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.3);
  font-size: 0.85rem;
}

.skill-tag button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.skill-add-row {
  align-items: end;
  margin-top: 0.5rem;
}

.budget-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.budget-bar.over {
  color: var(--danger);
}

.dot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.dot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.dot-row--readonly {
  opacity: 0.72;
}

.dot-row--readonly label {
  color: var(--text-muted);
}

.dot-row label {
  flex: 1 1 auto;
  font-size: 0.85rem;
}

.dots {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #5c6575;
  background: var(--dot-empty);
  cursor: pointer;
  padding: 0;
}

.dot.filled {
  background: radial-gradient(circle at 30% 25%, #ffe6a1, var(--dot-fill));
  border-color: #e3c56f;
}

.dot:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.dot.dot-capped:disabled {
  opacity: 0.32;
  cursor: not-allowed;
  border-color: #4a5260;
  background: rgba(40, 44, 52, 0.6);
}

.dot.filled.dot-locked-fill,
.dot.filled.dot-capped:disabled {
  cursor: not-allowed;
}

.dot.filled.dot-locked-fill {
  opacity: var(--dot-locked-fill-opacity);
  border-color: var(--dot-locked-fill-border);
  background: var(--dot-locked-fill-bg);
  filter: var(--dot-locked-fill-filter);
}

.list-item {
  display: grid;
  gap: 0.5rem;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
}

.list-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.list-item-header label {
  margin: 0;
  font-weight: 600;
  color: var(--accent-2);
}

.btn-remove {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.25);
  flex-shrink: 0;
}

.btn-remove:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
}

.wizard-controls {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.character-sheet {
  display: grid;
  gap: 1rem;
}

.sheet-section {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.15);
}

.sheet-section h3 {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem;
}

.stat-pill {
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
}

.stat-pill strong {
  display: block;
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.75rem;
}

.sheet-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.45rem;
}

.sheet-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.sheet-stat-label {
  font-size: 0.85rem;
  color: var(--text);
}

.dots--readonly .dot {
  cursor: default;
  pointer-events: none;
}

.condition-track {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.track-band {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.track-band-label {
  flex: 0 0 7.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.track-band-hint {
  display: block;
  font-size: 0.7rem;
  color: rgba(148, 163, 184, 0.75);
}

.track-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.track-box {
  width: 16px;
  height: 16px;
  border: 2px solid #5c6575;
  border-radius: 3px;
  background: rgba(20, 22, 32, 0.9);
  flex-shrink: 0;
}

.track-box.filled {
  background: linear-gradient(180deg, #6b4f8a 0%, #4a3560 100%);
  border-color: #a78bfa;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.health-track .track-box.filled {
  background: linear-gradient(180deg, #8b3a3a 0%, #5c2020 100%);
  border-color: #f87171;
}

.quiet-track .track-box.filled {
  background: linear-gradient(180deg, #4c3d8f 0%, #2e2458 100%);
  border-color: #c4b5fd;
}

.sheet-derived-note {
  margin: 0.75rem 0 0;
}

.preview-tracks {
  margin-top: 0.75rem;
}

.preview-tracks .track-band-label {
  flex-basis: 4.5rem;
  font-size: 0.72rem;
}

.preview-tracks .track-box {
  width: 12px;
  height: 12px;
}

.preview-tracks .condition-track {
  gap: 0.35rem;
}

.error-box {
  padding: 1rem;
  border-radius: 10px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
  margin-bottom: 1rem;
}

.error-box ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.sheet-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.muted {
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .hero,
  .feature-grid,
  .wizard-layout {
    grid-template-columns: 1fr;
  }

  .wizard-sidebar {
    position: static;
  }
}

/* Reference Library */
.library-layout {
  max-width: 1100px;
  margin: 0 auto;
}

.library-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.library-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
}

.library-tab.active {
  border-color: var(--accent);
  color: var(--accent);
}

.library-body {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
}

.library-list-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.library-list-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.library-category {
  list-style: none;
  margin: 0.75rem 0 0.25rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

/* Tag twist widgets — collapsible categories */
.tag-twist-stack {
  display: block;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
}

#character-tags-picker.tag-twist-stack,
.catalog-twist-stack {
  max-height: 280px;
  overflow-y: auto;
}

#character-tags-picker.tag-twist-stack {
  max-height: 420px;
}

.library-entry-list.tag-twist-stack {
  max-height: calc(60vh - 4rem);
  overflow-y: auto;
}

.tag-twist-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.tag-twist {
  display: block;
  margin-bottom: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.tag-twist:last-child {
  margin-bottom: 0;
}

.tag-twist-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  background: rgba(167, 139, 250, 0.06);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-align: left;
}

.tag-twist-toggle:hover {
  background: rgba(167, 139, 250, 0.12);
}

.tag-twist-label {
  flex: 1;
}

.tag-twist-chevron {
  display: inline-block;
  width: 1rem;
  color: var(--accent);
  transition: transform 0.15s ease;
}

.tag-twist:not(.is-open) .tag-twist-chevron {
  transform: rotate(-90deg);
}

.tag-twist-count {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
}

.tag-twist-panel {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-top: 1px solid var(--border);
  padding: 0.35rem 0.75rem 0.65rem;
}

.tag-twist:not(.is-open) .tag-twist-panel {
  display: none;
}

.tag-option-name {
  font-weight: 500;
}

.tag-twist-panel .tag-option {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.35rem 0.5rem;
}

.tag-option {
  padding: 0.35rem 0.25rem;
  border-radius: 6px;
  cursor: pointer;
}

.tag-option:hover {
  background: rgba(167, 139, 250, 0.06);
}

.tag-option input {
  margin-top: 0.15rem;
  accent-color: var(--accent);
}

.tag-option-hint {
  flex: 1 1 100%;
  font-size: 0.78rem;
  line-height: 1.35;
  margin-left: 1.35rem;
}

.tag-selected-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
  min-height: 1.5rem;
}

.tag-chip {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(167, 139, 250, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: var(--text);
}

.tag-twist-panel .library-entry {
  margin: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}

.library-entry-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.library-entry {
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}

.library-entry:hover,
.library-entry.active {
  background: rgba(167, 139, 250, 0.08);
  border-color: rgba(167, 139, 250, 0.25);
}

.library-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.library-form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.list-item.compact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
}

@media (max-width: 900px) {
  .library-body {
    grid-template-columns: 1fr;
  }
}
