@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,500;9..144,600;9..144,700;9..144,900&family=Inter+Tight:wght@400;500;600;700&display=swap');

:root {
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-elevated: #f1f5f9;
  --ink: #1f2937;
  --ink-dim: #6b7280;
  --ink-faint: #9ca3af;
  --accent: #b21918;
  --accent-soft: rgba(178, 25, 24, 0.08);
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --wisper-blue: #25378a;
  --wisper-red: #b21918;
  --screen-blue: #6b84c8;
  --dark-blue: #20294f;

  --r-rescuer:   #8b5cf6;
  --r-enforcer:  #7c3aed;
  --r-fixer:     #6366f1;
  --r-harmonizer:#06b6d4;
  --r-adapter:   #10b981;
  --r-driver:    #f59e0b;

  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter Tight', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  overscroll-behavior: none;
}

body {
  background-image:
    radial-gradient(circle at 20% 0%, rgba(106, 27, 154, 0.04) 0%, transparent 60%),
    radial-gradient(circle at 80% 100%, rgba(106, 27, 154, 0.03) 0%, transparent 60%);
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 20px 100px;
  min-height: 100vh;
}

/* ===== HEADER ===== */
.header {
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.header .eyebrow {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.header h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-style: italic;
}
.header h1 em {
  font-style: normal;
  font-weight: 500;
}

/* ===== PROGRESS ===== */
.progress-wrap {
  margin-bottom: 24px;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
}
.progress-meta .section {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--wisper-blue);
}
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--wisper-blue);
}
.progress-fill {
  height: 100%;
  background: var(--wisper-blue);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== INTRO ===== */
.intro {
  padding: 8px 0;
}
.intro h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.15;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}
.intro p {
  color: var(--ink-dim);
  font-size: 15px;
  margin-bottom: 14px;
  line-height: 1.6;
}
.intro ul {
  list-style: none;
  margin: 20px 0 28px;
  padding: 0;
}
.intro ul li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 10px;
  color: var(--ink-dim);
  font-size: 14px;
}
.intro ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 9px;
  width: 12px;
  height: 1px;
  background: var(--accent);
}
.intro .meta {
  display: flex;
  gap: 16px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-faint);
}
.intro .meta span {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== QUESTION ===== */
.question {
  animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.q-number {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}
.q-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  line-height: 1.25;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}
.q-scenario {
  color: var(--ink-dim);
  font-size: 15px;
  line-height: 1.55;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.option {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: left;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  line-height: 1.45;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  width: 100%;
}
.option:hover, .option:focus-visible {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
  outline: none;
}
.option:active {
  transform: scale(0.99);
}
.option.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-dim);
  margin-top: 1px;
  transition: all 0.18s ease;
}
.option.selected .option-letter {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-style: normal;
  font-weight: 600;
}

/* ===== NAV ===== */
.nav-bar {
  margin-top: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.btn {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 22px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  letter-spacing: 0.01em;
}
.btn:hover:not(:disabled) {
  background: var(--bg-card);
  border-color: var(--ink-faint);
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
  padding: 14px 28px;
}
.btn-primary:hover:not(:disabled) {
  background: #911d1d;
  border-color: #911d1d;
}
.btn-block {
  width: 100%;
  padding: 16px 28px;
  font-size: 15px;
}

/* ===== RESULTS ===== */
.results h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.15;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
  font-style: italic;
}
.results .lead {
  color: var(--ink-dim);
  font-size: 15px;
  margin-bottom: 28px;
  line-height: 1.55;
}
.top-pattern {
  background: var(--bg-card);
  border: 2px solid var(--wisper-blue);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 28px;
}
.top-pattern .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.top-pattern .name {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.top-pattern .band {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 12px;
}
.top-pattern .risk {
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.55;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.top-pattern .risk strong {
  color: var(--ink);
  font-weight: 600;
}

.scores-section {
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--wisper-blue);
  border-radius: 12px;
  margin-bottom: 28px;
}
.scores-section h3 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 20px;
  margin-bottom: 16px;
  color: var(--wisper-blue);
}
.score-row {
  margin-bottom: 18px;
}
.score-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.score-row-name {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.score-row-band {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-dim);
}
.score-row-val {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 14px;
  color: var(--ink-dim);
  margin-left: 6px;
}
.score-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.score-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.interp-key {
  margin-top: 32px;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--wisper-blue);
  border-radius: 10px;
}
.interp-key h4 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--wisper-blue);
}
.interp-key-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-dim);
  padding: 4px 0;
  font-variant-numeric: tabular-nums;
}

.reflection {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.reflection h3 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  margin-bottom: 6px;
}
.reflection p.sub {
  font-size: 13px;
  color: var(--ink-faint);
  margin-bottom: 20px;
  font-style: italic;
}
.reflection ol {
  list-style: none;
  counter-reset: rq;
  padding: 0;
}
.reflection ol li {
  counter-increment: rq;
  position: relative;
  padding-left: 32px;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
.reflection ol li::before {
  content: counter(rq, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--accent);
}

.submit-section {
  margin-top: 36px;
  padding: 22px;
  background: var(--bg-card);
  border: 1px solid var(--wisper-blue);
  border-radius: 12px;
}
.submit-section h3 {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 6px;
}
.submit-section p {
  color: var(--ink-dim);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.input-field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.18s ease;
}
.input-field:focus {
  border-color: var(--accent);
}
.submit-status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--accent);
  font-style: italic;
  text-align: center;
}

.restart {
  margin-top: 28px;
  text-align: center;
}
.restart button {
  background: none;
  border: none;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.restart button:hover { color: var(--ink); }

.footer-note {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-faint);
  line-height: 1.5;
}

/* ===== SITE NAV ===== */
.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.site-nav a,
.site-nav button {
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-dim);
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.18s ease;
}
.site-nav a:hover,
.site-nav button:hover {
  background: var(--bg-elevated);
  color: var(--ink);
}
.site-nav .logout {
  color: var(--ink-faint);
}
.site-nav .logout:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ===== DASHBOARD ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 28px;
}
.survey-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  color: var(--ink);
  display: block;
}
.survey-card:hover {
  border-color: var(--wisper-blue);
  box-shadow: 0 2px 12px rgba(37, 55, 138, 0.08);
}
.survey-card .card-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.survey-card h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 18px;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.survey-card p {
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.5;
}
.survey-card .card-meta {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-faint);
  display: flex;
  gap: 12px;
}

/* ===== QR CODE ===== */
#qrCodeContainer {
  margin-top: 28px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}
#qrCodeContainer img {
  max-width: 120px;
  border-radius: 4px;
}
#qrCodeContainer p {
  font-size: 11px;
  color: var(--ink-faint);
  margin: 8px 0 0 0;
}

/* ===== UTILITY ===== */
.hidden { display: none !important; }

/* ===== AUTH OVERLAY ===== */
.auth-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--ink-dim);
  font-size: 15px;
  font-family: var(--sans);
}
.auth-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--wisper-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 380px) {
  .app { padding: 20px 16px 80px; }
  .header h1 { font-size: 24px; }
  .q-title { font-size: 20px; }
  .intro h2 { font-size: 28px; }
  .results h2 { font-size: 26px; }
}