:root {
  --brand: #479ed9;
  --brand-dark: #2c7eb8;
  --brand-tint: #eaf4fb;
  --ink: #1f2a37;
  --ink-soft: #4b5563;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f7fafc;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  background: var(--brand);
  color: #fff;
  padding: 18px 24px;
  box-shadow: var(--shadow);
}

.brand {
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand-logo {
  width: 120px;
  height: auto;
  flex-shrink: 0;
  display: block;
}

.brand-tagline {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
  color: #fff;
}

@media (max-width: 520px) {
  .site-header {
    padding: 14px 16px;
  }
  .brand {
    gap: 14px;
  }
  .brand-logo {
    width: 88px;
  }
  .brand-tagline {
    font-size: 13px;
  }
}

/* Layout */
.container {
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 48px;
  flex: 1;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  padding: 24px 16px 32px;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  margin-bottom: 24px;
}

@media (max-width: 600px) {
  .card {
    padding: 22px;
  }
  .container {
    padding: 20px 14px 36px;
  }
}

/* Typography */
h1 {
  font-size: 26px;
  margin: 0 0 12px;
  color: var(--ink);
}

h2 {
  font-size: 19px;
  margin: 28px 0 12px;
  color: var(--ink);
}

p {
  margin: 0 0 12px;
}

.lede {
  font-size: 17px;
  color: var(--ink-soft);
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

/* Forms */
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-soft);
}

input[type='text'],
input[type='password'],
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(71, 158, 217, 0.18);
}

/* Buttons */
.btn-primary,
.btn-secondary {
  appearance: none;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.04s ease;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-secondary:hover {
  background: var(--brand-tint);
  border-color: var(--brand);
  color: var(--brand-dark);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button:active {
  transform: translateY(1px);
}

/* Survey */
.progress {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  margin-bottom: 18px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--brand);
  transition: width 0.2s ease;
  width: 0%;
}

.section-meta {
  font-size: 13px;
  color: var(--brand-dark);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.question-title {
  font-size: 21px;
  margin: 0 0 8px;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
}

.question-help {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 18px;
}

.question-body {
  margin-bottom: 24px;
}

.survey-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

/* Option chips (single + multi) */
.options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.option {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  user-select: none;
  transition: all 0.12s ease;
}

.option:hover {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.option.selected {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

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

/* Spectrum */
.spectrum {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.spectrum-anchors {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  gap: 12px;
}

.spectrum-anchors > span {
  flex: 1;
}

.spectrum-anchors > span:last-child {
  text-align: right;
}

.spectrum-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.spectrum-step {
  text-align: center;
  padding: 14px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 16px;
  transition: all 0.12s ease;
}

.spectrum-step:hover {
  border-color: var(--brand);
  background: var(--brand-tint);
}

.spectrum-step.selected {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* Open text */
.open-input {
  width: 100%;
}

/* Profile / results */
.profile-card .participant-name {
  font-size: 17px;
  color: var(--brand-dark);
  font-weight: 600;
  margin-bottom: 18px;
}

.profile-summary,
.how-to-card {
  background: var(--brand-tint);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.summary-line {
  margin: 0 0 8px;
}

.how-to-card dl {
  margin: 0;
  display: grid;
  gap: 12px;
}

.how-to-card dt {
  font-weight: 700;
  color: var(--brand-dark);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.how-to-card dd {
  margin: 4px 0 0;
  white-space: pre-wrap;
}

.results-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.submit-status {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
}

.submit-status.success {
  color: var(--brand-dark);
  font-weight: 600;
}

.submit-status.error {
  color: #b42318;
  font-weight: 600;
}

/* Team view */
.team-actions {
  display: flex;
  gap: 12px;
  margin: 12px 0 18px;
  flex-wrap: wrap;
}

.friction-list {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.friction-item {
  border-left: 4px solid var(--brand);
  background: var(--brand-tint);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.friction-item h3 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--brand-dark);
}

.friction-item p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.distributions {
  display: grid;
  gap: 18px;
  margin-bottom: 12px;
}

.dist {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: #fff;
}

.dist h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.dist .anchors {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.dist .bars {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  align-items: end;
  height: 80px;
}

.dist .bar {
  background: var(--brand);
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 4px;
}

.dist .bar-count {
  position: absolute;
  top: -18px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
}

.dist .bar-label {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.dist-bars-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 4px;
}

/* Categorical bars (chips style for multi/single options) */
.cat-list {
  display: grid;
  gap: 8px;
}

.cat-row {
  display: grid;
  grid-template-columns: 1fr 60px;
  gap: 10px;
  align-items: center;
  font-size: 14px;
}

.cat-bar {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.cat-bar-fill {
  height: 100%;
  background: var(--brand);
}

.cat-count {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: right;
}

/* Cards grid for individual how-to cards */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.person-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: #fff;
}

.person-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
  color: var(--brand-dark);
}

.person-card .field-row {
  margin-bottom: 8px;
  font-size: 14px;
}

.person-card .field-row strong {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
}

/* Admin: teams list */
.teams-list {
  display: grid;
  gap: 12px;
}

.team-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: #fff;
}

.team-row-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.team-row-header h3 {
  margin: 0;
  font-size: 16px;
}

.btn-link-danger {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  padding: 4px 10px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  color: #b42318;
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn-link-danger:hover:not(:disabled) {
  background: rgba(180, 35, 24, 0.08);
  border-color: rgba(180, 35, 24, 0.25);
}

.btn-link-danger:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.team-row .meta {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.team-row .links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.copyable {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  word-break: break-all;
  cursor: pointer;
}

.copyable:hover {
  background: var(--brand-tint);
  border-color: var(--brand);
}

.auth-error {
  color: #b42318;
  font-size: 14px;
  min-height: 1.2em;
  margin: 0;
}

.team-context {
  background: var(--brand-tint);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.team-context strong {
  color: var(--brand-dark);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fade-in 0.12s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-dialog {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.25);
  padding: 28px;
  max-width: 560px;
  width: 100%;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.modal-dialog h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.modal-dialog > p {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 14px;
}

.copy-row {
  margin-bottom: 14px;
}

.copy-row > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.copy-row > label .muted {
  font-weight: 400;
  font-size: 13px;
  color: var(--muted);
}

.copy-row-control {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.copy-input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  cursor: text;
}

.copy-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(71, 158, 217, 0.18);
  background: #fff;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.copy-btn:hover {
  background: var(--brand-tint);
  border-color: var(--brand);
  color: var(--brand-dark);
}

.copy-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.copy-btn.copied {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.copy-btn.copied:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

.copy-row-static {
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

/* Print-only header (hidden in screen view, shown when printing) */
.print-only {
  display: none;
}

/* ---------- Print stylesheet ---------- */
@media print {
  /* Force colors to print correctly (so brand blue, bars, etc. appear) */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  @page {
    size: letter;
    margin: 0.6in 0.5in;
  }

  body {
    background: #fff !important;
    font-size: 11pt;
  }

  /* Hide interactive UI chrome */
  .site-header,
  .site-footer,
  .team-actions,
  .results-actions,
  .submit-status,
  button,
  .modal-overlay {
    display: none !important;
  }

  /* Reset container/card chrome — print is its own canvas */
  .container {
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .card {
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
    page-break-inside: auto;
  }

  /* Print-only header at top of every PDF */
  .print-only {
    display: block !important;
    padding-bottom: 12px;
    margin-bottom: 18px;
    border-bottom: 2px solid var(--brand);
  }

  .print-logo {
    width: 140px;
    height: auto;
    display: block;
    margin-bottom: 6px;
  }

  .print-meta {
    font-size: 10pt;
    color: var(--muted);
    margin: 0;
  }

  h1 {
    font-size: 20pt;
    margin: 0 0 4px;
    color: var(--ink);
  }

  h2 {
    font-size: 14pt;
    margin: 18px 0 8px;
    color: var(--brand-dark);
    page-break-after: avoid;
  }

  p {
    margin: 0 0 8px;
  }

  /* Friction items: keep each one together on a page */
  .friction-item {
    page-break-inside: avoid;
    background: var(--brand-tint) !important;
    border-left: 3px solid var(--brand) !important;
    padding: 10px 14px !important;
    margin-bottom: 10px;
  }

  /* Distribution charts: keep each chart together */
  .dist {
    page-break-inside: avoid;
    border: 1px solid var(--line) !important;
    margin-bottom: 12px;
    padding: 12px 14px !important;
  }

  .dist .bars {
    height: 64px;
  }

  .dist .bar {
    background: var(--brand) !important;
  }

  .cat-bar {
    background: var(--line) !important;
  }

  .cat-bar-fill {
    background: var(--brand) !important;
  }

  /* Person cards: keep each one together, 2 per row */
  .cards-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .person-card {
    page-break-inside: avoid;
    border: 1px solid var(--line) !important;
    padding: 12px !important;
    background: #fff !important;
  }

  .person-card h3 {
    color: var(--brand-dark);
    font-size: 12pt;
    margin: 0 0 8px;
  }

  .person-card .field-row {
    margin-bottom: 6px;
    font-size: 10pt;
  }

  .person-card .field-row strong {
    font-size: 9pt;
  }

  /* Profile card (participant results page) */
  .profile-summary,
  .how-to-card {
    background: var(--brand-tint) !important;
    page-break-inside: avoid;
    padding: 14px 16px !important;
  }

  .participant-name {
    color: var(--brand-dark);
    font-weight: 600;
  }

  /* Hyperlink URLs: don't show "(http://...)" after links */
  a[href]::after {
    content: none !important;
  }
}
