* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, sans-serif; margin: 0; padding: 0; background: #f5f5f7; color: #1d1d1f; }
.grace-header { background: #2c3e50; color: white; padding: 1rem 2rem; }
.grace-header h1 { margin: 0; font-size: 1.5rem; }
.subtitle { margin: 0.25rem 0 0; opacity: 0.8; font-size: 0.85rem; }
.layout { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; padding: 2rem; max-width: 1400px; margin: 0 auto; }
.form-column { background: white; padding: 2rem; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.debug-column { background: #1d1d1f; color: #f5f5f7; padding: 1.5rem; border-radius: 8px; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 0.85rem; overflow-x: auto; }
.debug-column h2 { margin-top: 0; font-size: 1rem; color: #94d8e0; }
.debug-column .section { margin: 1rem 0; padding-bottom: 1rem; border-bottom: 1px solid #333; }
.debug-column .section:last-child { border-bottom: none; }
.debug-column .section h3 { font-size: 0.8rem; text-transform: uppercase; color: #94d8e0; margin: 0 0 0.5rem; }
.debug-column .empty { color: #888; font-style: italic; }
.step { margin-bottom: 1.25rem; }
.step label { display: block; margin-bottom: 0.4rem; font-weight: 500; font-size: 0.9rem; }
.step input, .step select { width: 100%; padding: 0.6rem; border: 1px solid #d2d2d7; border-radius: 6px; font-size: 1rem; }
#submit-btn { width: 100%; padding: 0.9rem; background: #6e6e73; color: white; border: none; border-radius: 6px; font-size: 1rem; cursor: pointer; }
#submit-btn:hover { background: #515154; }
#submit-btn.cta-bucket-b { background: #d63232; }
#submit-btn.cta-bucket-b:hover { background: #b02828; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

/* ---- Step funnel layout ---- */

.progress-dots { list-style: none; padding: 0; margin: 0 0 1.5rem; display: flex; gap: 0.4rem; justify-content: center; }
.progress-dots li { width: 32px; height: 4px; border-radius: 2px; background: #d2d2d7; }
.progress-dots li.done { background: #94d8e0; }
.progress-dots li.active { background: #2c3e50; }

.step { display: none; }
.step.is-active { display: block; }
.step h2 { margin: 0 0 1rem; font-size: 1.15rem; }
.step label { display: block; margin: 0.75rem 0 0.3rem; font-weight: 500; font-size: 0.9rem; }
.step input, .step select {
  width: 100%; padding: 0.6rem; border: 1px solid #d2d2d7;
  border-radius: 6px; font-size: 1rem;
}
.helper { color: #6e6e73; font-size: 0.8rem; margin: 0.5rem 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.nav-row { display: flex; gap: 0.5rem; margin-top: 1.5rem; }
.nav-btn { padding: 0.8rem; border: none; border-radius: 6px; font-size: 1rem; cursor: pointer; }
.nav-back { flex: 0 0 100px; background: #e5e5ea; color: #1d1d1f; }
.nav-back:disabled { opacity: 0.5; cursor: not-allowed; }
.nav-next, .nav-submit { flex: 1; background: #2c3e50; color: white; }
.nav-next:hover, .nav-submit:hover { background: #1e2a36; }
.nav-submit.cta-bucket-b { background: #d63232; }
.nav-submit.cta-bucket-b:hover { background: #b02828; }

/* ---- Debug panel demo-loud vocabulary ---- */

.debug-column .conf-red { color: #f87171; font-weight: 700; }
.debug-column .conf-amber { color: #fbbf24; font-weight: 700; }
.debug-column .conf-green { color: #4ade80; font-weight: 700; }

.debug-column .grade-border-session    { border-left: 3px solid #94d8e0; padding-left: 0.6rem; }
.debug-column .grade-border-experiment { border-left: 3px solid #fbbf24; padding-left: 0.6rem; }
.debug-column .grade-border-submission { border-left: 3px solid #4ade80; padding-left: 0.6rem; }

.debug-column .chip { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 10px;
                      font-size: 0.7rem; font-weight: 600; margin-left: 0.25rem; }
.debug-column .chip-green { background: #134e2a; color: #4ade80; }
.debug-column .chip-amber { background: #533a08; color: #fbbf24; }
.debug-column .chip-bucket { background: #312e81; color: #c4b5fd; }

.debug-column .hit-banner { background: #14532d; color: #86efac; padding: 0.5rem;
                             border-radius: 4px; margin: 0 -0.5rem 0.75rem;
                             text-align: center; font-weight: 600; }
.debug-column .historical-badge { display: inline-block; background: #1e3a8a; color: #93c5fd;
                                   padding: 0.1rem 0.4rem; border-radius: 3px;
                                   font-size: 0.65rem; margin-left: 0.25rem; }

/* Spec §4.8: historical-context arrays render as bullet lists capped at 10. */
.debug-column ul.hist-array { list-style: disc inside; margin: 0.25rem 0 0.5rem 0;
                              padding: 0; font-size: 0.72rem; color: #cbd5e1; }
.debug-column ul.hist-array li { line-height: 1.25; }
.debug-column ul.hist-array li.hist-overflow { color: #94a3b8; }

.debug-column .flash { animation: debugFlash 1.2s ease-out; }
@keyframes debugFlash {
  0% { background: rgba(74, 222, 128, 0); }
  15% { background: rgba(74, 222, 128, 0.3); }
  100% { background: rgba(74, 222, 128, 0); }
}

/* ---- HIT card ---- */

.hit-card-overlay {
  background: linear-gradient(135deg, #e8f9f1 0%, #d1f4e0 100%);
  border: 2px solid #14b8a6; padding: 1.25rem; border-radius: 8px;
  margin: 0; color: #1d1d1f;
}
.hit-card-overlay h2 { color: #047857; margin: 0 0 0.5rem; }
.hit-card-overlay .hit-sub { color: #065f46; font-size: 0.85rem; margin: 0 0 0.75rem; }
.hit-card-overlay .known-values { background: white; padding: 0.75rem; border-radius: 4px;
                                   margin: 0.5rem 0; font-family: ui-monospace, monospace; font-size: 0.8rem; }
.hit-card-overlay .known-values dl { margin: 0; display: grid; grid-template-columns: 120px 1fr; gap: 0.25rem 0.75rem; }
.hit-card-overlay .known-values dt { color: #6b7280; font-weight: normal; }
.hit-card-overlay .known-values dd { margin: 0; }
.hit-card-overlay .historical-block { background: #f0fdf4; padding: 0.75rem; border-radius: 4px;
                                        margin: 0.75rem 0; font-size: 0.8rem; color: #065f46; }
.hit-cta-primary { width: 100%; padding: 0.9rem; background: #047857; color: white;
                   border: none; border-radius: 6px; font-size: 0.95rem; font-weight: 600;
                   cursor: pointer; margin-top: 0.5rem; }
.hit-cta-secondary { width: 100%; padding: 0.6rem; background: transparent; color: #065f46;
                      border: 1px solid #14b8a6; border-radius: 6px; font-size: 0.85rem;
                      cursor: pointer; margin-top: 0.4rem; }

/* ---- Task 28: inline email-step consent ---- */

.consent-inline {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 16px;
  font-size: 14px;
  line-height: 1.4;
}
.consent-inline input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
}
.consent-error {
  margin-top: 8px;
  padding: 8px 12px;
  background: #fff3f3;
  border: 1px solid #d34;
  color: #a22;
  font-size: 13px;
  border-radius: 4px;
}
.consent-error button {
  margin-left: 4px;
  background: none;
  border: none;
  color: #a22;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

/* ---- Task 29: submit-step TCPA + chain-link HIT card ---- */

/* Hide legacy #submit-btn on the loan_reason step so our opt-in/opt-out
   buttons are the only submit path (guarantees consent fires before /submit).
   NOTE: .nav-row is a sibling of the step sections (not a child), so we use
   a general sibling combinator off the form container instead. The legacy
   identity-sdk.js already manages submit-btn visibility via JS (hidden attr),
   but this CSS rule adds a hard visual guard for the last step. */
.step[data-step="loan_reason"].is-active ~ .nav-row #submit-btn {
  display: none !important;
}

.submit-block {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  background: #f8f8fa;
}
.tcpa-text {
  margin: 0 0 0.75rem;
  font-size: 13px;
  line-height: 1.5;
  color: #333;
}
.submit-block .nav-btn {
  margin-right: 8px;
  margin-bottom: 4px;
}
.submit-block .secondary {
  opacity: 0.85;
}
