:root {
  /* Primary Base */
  --color-primary: #FFFFFF;

  /* Surfaces */
  --color-surface: #F8F6FC;
  --color-border: #E0DCEB;

  /* Text */
  --color-text-primary: #24304C;
  --color-text-secondary: #656C84;

  /* Actions */
  --color-cta: #2E7AFF;
  --color-accent-violet: #7658C4;
  --color-accent-teal: #4DC4C9;
  --color-accent-coral: #F38E54;

  /* Status */
  --color-success: #48B478;
  --color-warning: #F5BE46;
  --color-error: #E15C5C;

  /* Typography */
  --font-heading: 'Sora', sans-serif;
  --font-subheading: 'Manrope', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(36, 48, 76, 0.05);
  --shadow-md: 0 4px 6px rgba(36, 48, 76, 0.07);
  --shadow-lg: 0 10px 15px rgba(36, 48, 76, 0.1);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 350ms ease;

  /* Typographic bases */
  --type-h1-base: 2.5rem;
  --type-h2-base: 2rem;
  --type-h3-base: 1.5rem;
  --type-p-base: 1rem;
  --type-xs: 0.75rem;
  --type-sm: 0.875rem;
  --type-md: 1rem;
  --type-lg: 1.25rem;
  --type-max: 1.75rem;
  --page-bg-radial: rgba(111, 181, 214, 0.12);
  --page-bg-start: #f5fbff;
  --page-bg-end: #eaf2f8;
}

:root[data-bs-theme="dark"] {
  --color-primary: #0f1724;
  --color-surface: #152033;
  --color-border: #2a3a55;
  --color-text-primary: #ebf2ff;
  --color-text-secondary: #a6b4ce;
  --color-cta: #8f73e6;
  --color-accent-violet: #8f73e6;
  --color-accent-teal: #3ba7ad;
  --color-accent-coral: #e08a54;
  --color-success: #4dbf86;
  --color-warning: #f2c55b;
  --color-error: #ef8080;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  --surface: #0f1724;
  --surface-muted: #182438;
  --surface-strong: #1d2b42;
  --ink-strong: #ebf2ff;
  --ink-soft: #9eb0cb;
  --border-soft: rgba(166, 180, 206, 0.28);
  --page-bg-radial: rgba(92, 115, 158, 0.22);
  --page-bg-start: #0b1320;
  --page-bg-end: #131f31;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
}

body {
  color: var(--color-text-primary);
  background-color: var(--color-primary);
  background-image:
    radial-gradient(circle at top, var(--page-bg-radial), transparent 30%),
    linear-gradient(180deg, var(--page-bg-start) 0%, var(--page-bg-end) 100%);
  line-height: 1.2rem;
  margin: 0;
  padding: 0;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: env(safe-area-inset-right);
  overflow-x: hidden;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

@media (max-width: 640px) {
  :root {
    --type-h1-base: 2.05rem;
    --type-h2-base: 1.65rem;
    --type-h3-base: 1.25rem;
    --type-p-base: 0.95rem;
  }

  body {
    padding-left: env(safe-area-inset-left);
  }
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  margin: 0 0 var(--space-md);
  color: var(--color-text-primary);
}

h1 { font-size: min(calc(var(--type-h1-base) * var(--app-h1-scale, 1)), var(--type-max)); }
h2 { font-size: min(calc(var(--type-h2-base) * var(--app-h2-scale, 1)), var(--type-max)); }
h3 { font-size: min(calc(var(--type-h3-base) * var(--app-h3-scale, 1)), var(--type-max)); }
h4 { font-size: var(--type-lg); }

p {
  font-size: calc(var(--type-p-base) * var(--app-p-scale, 1));
  margin: 0 0 var(--space-md);
}

.btn {
  font-weight: 500;
  padding: var(--space-sm) var(--space-lg);
  border-radius: 90px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.btn-primary {
  background-color: var(--color-accent-violet);
  color: white;
}

.btn-primary:hover {
  background-color: #5f44a3;
}

.btn-secondary {
  background-color: var(--color-accent-violet);
  color: white;
}

.btn-secondary:hover {
  background-color: #5f44a3;
}

.btn-outline {
  background-color: transparent;
  border: 2px solid var(--color-border);
  color: var(--color-text-primary);
}

.btn-outline:hover {
  border-color: var(--color-cta);
  color: var(--color-cta);
}

/* Temporarily defer to Bootstrap defaults for form controls.
.form-control {
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: white;
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--color-cta);
  box-shadow: 0 0 0 3px rgba(46, 122, 255, 0.15);
}

.form-control::placeholder {
  color: var(--color-text-secondary);
}

.form-select {
  padding: var(--space-sm) calc(var(--space-md) + 1.5rem) var(--space-sm) var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: white;
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  background-image: var(--bs-form-select-bg-img, none);
}
*/

.card {
  background-color: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

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

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

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

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

.bg-surface {
  background-color: var(--color-surface);
}

.bg-white {
  background-color: white;
}

/* Gradients */
.gradient-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent-violet) 100%);
}

.gradient-calm {
  background: linear-gradient(135deg, var(--color-accent-teal) 0%, var(--color-cta) 100%);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.animate-fade-in {
  animation: fadeIn var(--transition-base) ease-out;
}

.animate-slide-up {
  animation: slideUp var(--transition-slow) ease-out;
}

/* Utility Classes */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

.m-0 { margin: 0; }
.mt-md { margin-top: var(--space-md); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.text-center { text-align: center; }
.text-sm { font-size: var(--type-sm); }
.text-lg { font-size: calc(var(--type-md) * 1.125); }
.text-xl { font-size: var(--type-lg); }
.text-2xl { font-size: calc(var(--type-lg) * 1.2); }
.text-3xl { font-size: min(calc(var(--type-lg) * 1.6), var(--type-max)); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* App Header */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: transparent;
  z-index: 1000;
}

.app-header__home {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  user-select: none;
}

.app-header__theme-toggle {
  position: fixed;
  top: calc(0.45rem + env(safe-area-inset-top));
  left: calc(0.75rem + env(safe-area-inset-left));
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--color-primary) 92%, transparent);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-sm);
  font-size: var(--type-xs);
  font-weight: 700;
  line-height: 1;
}

.app-header__theme-toggle:hover {
  border-color: var(--color-accent-violet);
}

.app-header__theme-toggle:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--color-accent-violet) 60%, white);
  outline-offset: 2px;
}

.app-header__theme-toggle-icon {
  font-size: 0.85rem;
}

.app-header__logo {
  width: 32px;
  height: auto;
}

.app-header__brand {
  font-size: var(--type-sm);
  font-weight: 700;
  color: var(--color-text-secondary);
  opacity: 0.7;
}

.app-session-badge {
  position: fixed;
  top: 0.75rem;
  right: 1rem;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
}

.app-session-badge__dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--color-success);
  flex: 0 0 auto;
}

.app-session-badge__link {
  display: inline-flex;
  flex-direction: column;
  gap: 0.05rem;
  color: var(--color-text-primary);
}

.app-session-badge__link span {
  font-size: var(--type-xs);
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.app-session-badge__link strong {
  font-size: var(--type-xs);
  font-weight: 700;
}

.app-session-badge__logout-form {
  margin: 0;
}

.app-session-badge__logout {
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--type-xs);
  font-weight: 700;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  border-radius: var(--radius-full);
}

.app-session-badge__logout:hover {
  color: var(--color-accent-violet);
  background: rgba(118, 88, 196, 0.08);
}

@media (max-width: 640px) {
  .app-stage-shell,
  .app-stage,
  .app-stage__inner,
  .stage-page {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .app-header__theme-toggle {
    top: calc(0.35rem + env(safe-area-inset-top));
    left: calc(0.55rem + env(safe-area-inset-left));
    min-height: 1.85rem;
    padding: 0.25rem 0.55rem;
  }

  .app-session-badge {
    top: calc(0.5rem + env(safe-area-inset-top));
    right: calc(0.75rem + env(safe-area-inset-right));
    max-width: calc(100vw - 1.5rem - env(safe-area-inset-left) - env(safe-area-inset-right));
  }

  .app-session-badge__link strong {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* App Sidebar */
.app-sidebar {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  padding: var(--space-sm) 0;
}

.app-sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding-left: 2rem;
}

@media (max-width: 640px) {
  .app-sidebar {
    display: none;
  }

  .app-sidebar__nav {
    display: none;
  }
}

.app-sidebar__link,
.app-sidebar__link[href] {
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-border);
  transition: all var(--transition-fast);
  text-decoration: none;
}

@media (max-width: 640px) {
  .app-sidebar__link,
  .app-sidebar__link[href] {
    width: 0;
    height: 0;
    border: 0;
  }

  .app-sidebar__link[href]:hover:not(.is-disabled) {
    transform: none;
  }
}

.app-sidebar__link[href]:hover:not(.is-disabled) {
  background: var(--color-cta);
  transform: scale(1.2);
}

.app-sidebar__link.is-disabled,
span.app-sidebar__link.is-disabled {
  background: var(--color-border);
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* Objective Chips */
.objective-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.objective-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  background: white;
  cursor: pointer;
  width: 100%;
  transition: all var(--transition-fast);
}

.objective-chip__label {
  font-size: .85rem; /* -- calc(var(--type-sm) * 0.9); --*/
}

.objective-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.objective-chip input:checked + .objective-chip__label {
  color: white;
}

.objective-chip:has(input:checked) {
  background: var(--color-cta);
  border-color: var(--color-cta);
}

/* Eyebrow */
.eyebrow {
  display: block;
  width: 100%;
  color: #3f789a;
  font-size: var(--type-xs);
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

/* Splash Logo */
.splash-logo {
  width: 120px;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* App Stage - Full viewport */
.app-frame {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

@supports (height: 100dvh) {
  .app-frame {
    height: 100dvh;
  }
}

.app-stage-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: calc(52px + env(safe-area-inset-top));
  padding-bottom: calc( env(safe-area-inset-bottom));
  min-height: 0;
  overflow: hidden;
}

.app-stage {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.app-stage__inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
  min-height: 0;
}

.stage-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-md);
}

.layout--test .stage-page {
  justify-content: flex-start;
  min-height: 100%;
}

.layout--test .question-actions {
  margin-top: auto;
}

.layout--test.is-authenticated .app-stage__inner {
  padding-bottom: calc(var(--space-md) + 72px + env(safe-area-inset-bottom));
}

.layout--default .app-stage__inner {
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
  .layout--test .app-stage {
    flex: 0 1 auto;
    aspect-ratio: auto;
  }

  .layout--test .app-stage__inner {
    height: auto;
    overflow-y: visible;
  }

  .layout--test .stage-page {
    min-height: auto;
  }

  .layout--test .question-card-panel {
    flex: 0 0 auto;
  }

  .layout--test .question-card-panel__body {
    min-height: 12rem;
  }

  .layout--test .teaser-card .question-card-panel__body {
    min-height: 17rem;
  }
}

@media (max-width: 767px) {
  .layout--test .question-actions {
    position: sticky;
    bottom: 0;
    z-index: 9;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    background: linear-gradient(to top, rgba(255, 255, 255, 0.98) 70%, rgba(255, 255, 255, 0));
  }

  :root[data-bs-theme="dark"] .layout--test .question-actions {
    background: linear-gradient(to top, rgba(15, 23, 36, 0.98) 70%, rgba(15, 23, 36, 0));
  }

  .layout--test .question-flow-form--premium {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }

  .layout--test .question-flow-form--premium .rating-bar-container {
    margin-bottom: 0.85rem;
  }

  .layout--test .question-flow-form--premium .question-actions {
    position: static;
    margin-top: 0;
    padding-bottom: 0;
    background: transparent;
  }

  :root[data-bs-theme="dark"] .layout--test .question-flow-form--premium .question-actions {
    background: transparent;
  }
}

/* Archetype Image in results */
.teaser-archetype-img {
  width: 80%;
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  margin: 0 auto;
  display: block;
}

@media (max-width: 767px) {
  .teaser-screen--full-results {
    flex: 0 0 auto;
    min-height: auto;
    justify-content: flex-start;
    gap: 0.65rem;
  }

  .teaser-screen--full-results .teaser-carousel {
    flex: 0 0 auto;
    gap: 0.55rem;
    padding: 0.75rem;
  }

  .teaser-screen--full-results .teaser-carousel .question-card-panel__body {
    min-height: 0;
  }

  .teaser-screen--full-results .teaser-card__copy {
    gap: 0.5rem;
  }

  .teaser-screen--full-results .teaser-archetype-img {
    width: min(62%, 13.75rem);
    max-width: 100%;
    margin-bottom: 0 !important;
  }

  .teaser-screen--full-results .teaser-carousel__footer {
    margin-top: 0.1rem;
  }

  .teaser-screen--full-results .teaser-ranking {
    gap: 0.5rem;
    margin-top: 0;
  }

  .teaser-screen--full-results .teaser-ranking__item {
    min-height: 3.8rem;
    padding: 0.65rem 0.55rem;
    border-radius: 1rem;
  }

  .teaser-screen--full-results > .question-actions {
    margin-top: 0.2rem;
  }

  .teaser-screen--full-results > .question-actions .app-cta {
    min-height: 3.05rem;
  }
}

@media (min-width: 768px) {
  .teaser-screen--results {
    flex: 0 0 auto;
    min-height: auto;
    justify-content: flex-start;
    gap: 0.9rem;
  }

  .teaser-screen--results .teaser-carousel {
    flex: 0 0 auto;
    gap: 0.7rem;
    padding: 0.85rem 0.9rem 0.75rem;
  }

  .teaser-screen--results .teaser-carousel .question-card-panel__body {
    min-height: 0;
  }

  .teaser-screen--results .teaser-card__copy {
    gap: 0.55rem;
  }

  .teaser-screen--results .teaser-card__headline {
    font-size: clamp(1.45rem, 2.2vw, 1.75rem);
  }

  .teaser-screen--results .teaser-card__summary {
    font-size: var(--type-md);
  }

  .teaser-screen--results .teaser-card__copy--unlock {
    gap: 0.45rem;
  }

  .teaser-screen--results .teaser-card__headline--unlock {
    font-size: clamp(1.25rem, 1.8vw, 1.55rem);
  }

  .teaser-screen--results .teaser-card__summary--unlock {
    font-size: var(--type-sm);
  }

  .teaser-screen--results .teaser-unlock-list {
    gap: 0.35rem;
  }

  .teaser-screen--results .teaser-unlock-list__item {
    font-size: var(--type-sm);
    line-height: 1.2;
  }

  .teaser-screen--results .teaser-archetype-img {
    width: clamp(11rem, 28vh, 16rem);
    max-width: 100%;
    margin-bottom: 0 !important;
  }

  .teaser-screen--results .teaser-carousel__footer {
    margin-top: 0.1rem;
  }

  .teaser-screen--results .teaser-ranking {
    margin-top: 0;
  }

  .teaser-screen--results > .question-actions {
    margin-top: 0.25rem;
  }
}
