:root {
  color-scheme: light;
  --ink: #1f2328;
  --muted: #67707a;
  --line: #dfe3e7;
  --panel: #ffffff;
  --page: #f4f1eb;
  --a: #e98f96;
  --b: #8fcf9b;
  --c: #8fb9df;
  --d: #f2d26b;
  --axis: #d7dde3;
  --axis-dark: #7f8892;
  --accent: #2f5f7f;
  --soft: #faf8f4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 16% 8%, rgb(255 247 226 / 0.95), transparent 28rem),
    radial-gradient(circle at 85% 12%, rgb(226 238 246 / 0.9), transparent 27rem),
    linear-gradient(180deg, #fbfaf7 0%, var(--page) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
a {
  font: inherit;
}

.app-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.intro-hero {
  display: grid;
  grid-template-columns: minmax(0, 780px);
  gap: 30px;
  align-content: center;
  min-height: min(520px, calc(100vh - 40px));
  padding: 42px 0 34px;
}

.intro-hero h1 {
  max-width: 760px;
  font-size: clamp(2.7rem, 5.6vw, 5.25rem);
}

.intro-lede {
  max-width: 620px;
  margin: 22px 0 0;
  color: #3f4851;
  font-size: clamp(1.08rem, 1.6vw, 1.28rem);
  line-height: 1.55;
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 28px;
}

.intro-actions span {
  color: var(--muted);
  font-size: 0.94rem;
}

.intro-button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.survey-page {
  padding-top: 16px;
}

.text-button {
  display: inline-flex;
  align-items: center;
  margin: 0 0 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 750;
  cursor: pointer;
}

.text-button::before {
  content: "<";
  margin-right: 8px;
  color: #8a7f72;
}

.text-button:hover {
  color: #1f4850;
}

.intro-cues {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  margin: 0;
  padding: 18px 0 0;
  border-top: 1px solid #ded7cd;
  color: #5f6871;
  font-size: 0.94rem;
  font-weight: 700;
  list-style: none;
}

.intro-cues li {
  display: flex;
  align-items: center;
  gap: 9px;
}

.intro-cues li::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.survey-header {
  padding-top: 28px;
  border-top: 1px solid #ded7cd;
}

.app-header,
.report-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2.25rem, 5vw, 4.2rem);
  font-weight: 650;
  line-height: 0.98;
  letter-spacing: 0;
}

.header-note {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
}

.survey-form {
  display: grid;
  gap: 18px;
}

.person-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
  background: rgb(255 255 255 / 0.72);
  border: 1px solid #e6e0d7;
  border-radius: 8px;
  box-shadow: 0 12px 34px rgb(31 35 40 / 0.06);
}

.name-field {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid #e7eaee;
  border-radius: 8px;
}

.name-field span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.name-field em {
  padding: 2px 7px;
  border-radius: 999px;
  background: #eff6ff;
  color: #235a7c;
  font-size: 0.67rem;
  font-style: normal;
  text-transform: uppercase;
}

.name-field input {
  width: 100%;
  height: 44px;
  padding: 8px 12px;
  border: 1px solid #cbd2d9;
  border-radius: 6px;
  background: #fff;
}

.name-field input:focus {
  border-color: var(--accent);
  outline: 3px solid rgb(125 92 52 / 0.16);
}

.name-field input:invalid:not(:placeholder-shown) {
  border-color: #bf6f55;
}

.name-field small {
  color: var(--muted);
  font-size: 0.78rem;
}

.question-list {
  display: grid;
  gap: 16px;
}

.question-card {
  display: grid;
  gap: 12px;
  padding: 22px;
  background: rgb(255 255 255 / 0.88);
  border: 1px solid rgb(255 255 255 / 0.9);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgb(31 35 40 / 0.08);
  backdrop-filter: blur(14px);
}

.question-title {
  margin: 0;
  max-width: 760px;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: 0;
}

.rank-guide {
  display: block;
  max-width: 720px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.rank-guide-bottom {
  margin-top: -2px;
}

.rank-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 76px 24px;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 9px 12px;
  border: 1px solid #d9e0e7;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.92) inset;
  user-select: none;
  touch-action: none;
  cursor: grab;
  will-change: transform;
}

.rank-item:hover {
  border-color: #aebdca;
  background: #fff;
  box-shadow: 0 12px 28px rgb(31 35 40 / 0.1);
}

.rank-item.dragging {
  cursor: grabbing;
  background: #fff;
  box-shadow: 0 18px 40px rgb(31 35 40 / 0.22);
  transform: scale(1.015);
}

.rank-placeholder {
  border: 1px dashed #94a9ba;
  border-radius: 8px;
  background: rgb(47 95 127 / 0.08);
  list-style: none;
}

.is-ranking,
.is-ranking * {
  cursor: grabbing !important;
}

.rank-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #eef1f4;
  color: #4f5964;
  font-weight: 750;
  font-size: 0.82rem;
}

.rank-text {
  min-width: 0;
  line-height: 1.33;
  font-size: 0.98rem;
}

.rank-handle {
  color: #a0a8b1;
  font-size: 1.05rem;
  text-align: center;
  line-height: 1;
}

.move-buttons {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.icon-button {
  width: 33px;
  height: 32px;
  border: 1px solid #d2d8df;
  border-radius: 6px;
  background: #f7f8fa;
  color: #46515c;
  cursor: pointer;
}

.icon-button:hover:not(:disabled) {
  background: #fff;
  border-color: #bfc7d1;
}

.icon-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.form-actions,
.screen-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  padding: 9px 14px;
  border-radius: 7px;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: #244e69;
}

.ghost-button {
  border: 1px solid #bcc3cc;
  background: #fff;
  color: #2e3338;
}

.screen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.email-status {
  min-height: 22px;
  margin: -4px auto 12px;
  width: min(8.5in, 100%);
  color: var(--muted);
  text-align: right;
}

.final-notice {
  margin: 0 auto 18px;
  padding: 14px 16px;
  border: 1px solid #cfe3d8;
  border-radius: 8px;
  background: #f5fbf7;
  color: #24473b;
  font-weight: 750;
  text-align: center;
}

.email-status[data-tone="error"] {
  color: #b64242;
  border-color: #ead0c8;
  background: #fff7f4;
}

.report-page,
.final-page {
  width: min(11in, 100%);
  min-height: 8.5in;
  margin: 0 auto;
  padding: 0.38in;
  background: #fff;
  border: 1px solid #e0ddd6;
  box-shadow: 0 18px 50px rgb(59 54 45 / 0.12);
}

.report-header {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid #ebe6de;
}

.report-header h2 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.1;
}

.report-meta {
  text-align: right;
  color: var(--muted);
}

.report-meta p {
  margin-bottom: 4px;
}

.report-body {
  display: grid;
  gap: 16px;
}

.pie-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.chart-panel {
  border: 1px solid #e3ded5;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfaf7 100%);
  padding: 12px;
  box-shadow: 0 8px 20px rgb(48 43 35 / 0.06);
}

.chart-panel h3 {
  margin-bottom: 10px;
  color: #565b60;
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pie-axis,
.pie-abcd {
  width: 100%;
  aspect-ratio: 1;
}

.pie-axis svg,
.pie-abcd svg {
  display: block;
  width: 100%;
  height: 100%;
}

.bar-panel {
  min-height: 310px;
}

.bar-chart {
  height: 258px;
}

.bar-chart svg {
  display: block;
  width: 100%;
  height: 100%;
}

.report-footer {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 1px solid #ebe6de;
  color: var(--muted);
  font-size: 0.78rem;
}

.axis-label {
  fill: #34383d;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

.abcd-label {
  fill: #30343a;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
}

.bar-label {
  fill: #4e555c;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
}

.bar-tick {
  fill: #7b8289;
  font-size: 12px;
  font-weight: 650;
}

.bar-gridline {
  stroke: #e2e3e4;
  stroke-width: 1;
}

.bar-baseline {
  stroke: #5b6065;
  stroke-width: 1.4;
}

.report-footer p {
  margin-bottom: 0;
}

.selection-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}

.selection-summary,
.selection-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.selection-summary {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
  padding: 18px;
}

.selection-summary h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
}

.selection-summary p {
  margin-bottom: 0;
  color: var(--muted);
}

.email-to-field {
  display: grid;
  gap: 5px;
  margin-top: 2px;
}

.email-to-field span {
  color: #3d454d;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.email-to-field input {
  width: 100%;
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid #cbd2d9;
  border-radius: 6px;
  background: #fff;
  font-size: 0.88rem;
}

.email-to-field input:focus {
  border-color: var(--accent);
  outline: 3px solid rgb(47 95 127 / 0.16);
}

.selection-list {
  display: grid;
  gap: 14px;
}

.selection-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #e1dbd2;
  border-radius: 8px;
  background: rgb(255 255 255 / 0.72);
}

.selection-card {
  padding: 18px;
}

.selection-card h2 {
  margin-bottom: 12px;
  font-size: 1.12rem;
}

.selection-lines {
  display: grid;
  gap: 8px;
}

.selection-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #d9dde2;
  border-radius: 7px;
  background: #fbfcfd;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.selection-line:hover {
  border-color: #c2cad3;
  background: #fff;
}

.selection-line:focus-visible {
  outline: 3px solid rgb(47 95 103 / 0.16);
  outline-offset: 2px;
}

.selection-line.is-selected {
  border-color: #8fcf9b;
  background: #f4fbf5;
  box-shadow: 0 8px 20px rgb(52 199 89 / 0.08);
}

.selection-line p {
  margin-bottom: 0;
}

.choice-toggle {
  display: grid;
  place-items: center;
  width: 30px;
  min-width: 30px;
  height: 30px;
  border: 1.5px solid #b9c1ca;
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.choice-toggle:hover {
  border-color: #7e8a96;
}

.choice-toggle:focus-visible {
  outline: 3px solid rgb(47 95 103 / 0.18);
  outline-offset: 2px;
}

.choice-toggle[aria-pressed="true"] {
  background: #34c759;
  border-color: #34c759;
}

.choice-toggle:active {
  transform: scale(0.96);
}

.checkmark-icon {
  width: 13px;
  height: 8px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  opacity: 0;
  transform: translateY(-1px) rotate(-45deg) scale(0.8);
  transition: opacity 140ms ease, transform 140ms ease;
}

.choice-toggle[aria-pressed="true"] .checkmark-icon {
  opacity: 1;
  transform: translateY(-1px) rotate(-45deg) scale(1);
}

.final-document {
  display: grid;
  justify-content: center;
}

.final-summary {
  display: grid;
  gap: 22px;
}

.pdf-page {
  width: min(8.5in, 100%);
  min-height: 10.65in;
  padding: 0.4in 0.46in;
  background: #fffdf8;
  border: 1px solid #e5ded4;
  box-shadow: 0 22px 60px rgb(59 54 45 / 0.12);
  position: relative;
  overflow: hidden;
}

.pdf-page::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 0;
}

.pdf-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 8px 0 14px;
  border-top: 1px solid #ded7cd;
  border-bottom: 0;
}

.pdf-header h2 {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  font-weight: 650;
  line-height: 0.98;
}

.pdf-subtitle {
  max-width: 440px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.style-marker {
  min-width: 124px;
  margin: 42px 0 0;
  padding: 12px 10px;
  border-top: 1px solid #d6cec2;
  border-bottom: 1px solid #d6cec2;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-align: right;
}

.pattern-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.pattern-block {
  display: grid;
  gap: 2px;
  padding: 10px;
  border-top: 6px solid;
  background: #f8f9fa;
}

.pattern-block strong {
  font-size: 1.4rem;
}

.pattern-block span {
  color: var(--muted);
  font-size: 0.82rem;
}

.report-intro {
  margin-bottom: 12px;
  padding: 12px 14px;
  background: #f7f3ea;
  border: 1px solid #eadfcd;
  border-left: 5px solid var(--accent);
  border-radius: 8px;
}

.report-intro h3,
.report-intro p {
  margin-bottom: 0;
}

.final-charts {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.final-chart-panel {
  border: 1px solid #e3dacf;
  border-radius: 4px;
  background: #fffefa;
  padding: 12px;
  box-shadow: 0 8px 24px rgb(59 54 45 / 0.06);
}

.final-chart-panel h3 {
  margin-bottom: 6px;
  color: #56616b;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.final-bar-chart {
  height: 215px;
}

.final-bar-chart svg,
.final-chart-panel svg {
  display: block;
  width: 100%;
  height: 100%;
}

.final-pie-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.final-pie-grid .final-chart-panel {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 132px;
}

.final-pie-grid .final-chart-panel h3 {
  order: 2;
  margin: 8px 0 0;
  color: #2e383f;
  font-size: 0.8rem;
  letter-spacing: 0;
  text-transform: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 26px;
}

.final-section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 30px;
  row-gap: 14px;
}

.summary-grid .final-section,
.final-section-grid .final-section {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.final-section h3 {
  margin-bottom: 9px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e8e1d7;
  color: #2e383f;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.18rem;
  font-weight: 650;
}

.final-section ul {
  margin: 0;
  padding-left: 18px;
}

.final-section li {
  margin-bottom: 5px;
}

.empty-summary {
  color: var(--muted);
}

@media (max-width: 850px) {
  .app-header,
  .report-header {
    display: grid;
  }

  .intro-hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 18px;
  }

  .report-page {
    padding: 18px;
  }

  .pdf-page {
    padding: 22px;
  }

  .selection-shell {
    grid-template-columns: 1fr;
  }

  .selection-summary {
    position: static;
  }

  .person-fields {
    grid-template-columns: 1fr;
  }

}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .survey-view,
  .report-view,
  .writing-view,
  .screen-actions,
  .email-status {
    display: none !important;
  }

  .final-view:not([hidden]) {
    display: block !important;
  }

  .report-view:not([hidden]) {
    display: block !important;
  }

  .report-view[hidden],
  .final-view[hidden] {
    display: none !important;
  }

  .report-view:not([hidden]) .report-page {
    width: 11in;
    min-height: 8.5in;
    border: 0;
    box-shadow: none;
    padding: 0.35in;
    page: chart;
  }

  .final-document {
    display: block;
  }

  .final-summary {
    display: block;
    gap: 0;
  }

  .pdf-page {
    width: 100%;
    min-height: 0;
    height: auto;
    border: 0;
    box-shadow: none;
    padding: 0.25in 0.34in;
    break-after: page;
    page-break-after: always;
  }

  .pdf-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .report-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
  }

  .report-header h2 {
    font-size: 1.45rem;
  }

  .report-body {
    gap: 12px;
  }

  .bar-panel {
    min-height: 260px;
  }

  .bar-chart {
    height: 212px;
  }

  .pie-row {
    gap: 10px;
  }

  .chart-panel {
    padding: 8px;
  }

  .chart-panel h3 {
    margin-bottom: 4px;
    font-size: 0.68rem;
  }

  .report-footer {
    margin-top: 10px;
    padding-top: 7px;
    font-size: 0.68rem;
  }

  .pdf-header h2 {
    font-size: 1.72rem;
    line-height: 0.98;
  }

  .pdf-header {
    margin-bottom: 9px;
    padding: 4px 0 6px;
  }

  .pdf-subtitle {
    max-width: 4.65in;
    margin-top: 5px;
    font-size: 0.69rem;
    line-height: 1.2;
  }

  .style-marker {
    min-width: 0;
    margin-top: 18px;
    padding: 6px 4px;
    font-size: 1rem;
    letter-spacing: 0.08em;
  }

  .final-charts {
    gap: 6px;
    margin-bottom: 9px;
  }

  .final-chart-panel {
    padding: 5px;
    border-radius: 3px;
    box-shadow: none;
  }

  .final-chart-panel h3 {
    margin-bottom: 3px;
    font-size: 0.62rem;
  }

  .final-bar-chart {
    height: 136px;
  }

  .final-pie-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .final-pie-grid .final-chart-panel {
    min-height: 86px;
  }

  .final-pie-grid .final-chart-panel h3 {
    margin-top: 3px;
    font-size: 0.56rem;
  }

  .report-intro {
    margin-bottom: 7px;
    padding: 7px 9px;
  }

  .final-section-grid {
    column-gap: 0.34in;
    row-gap: 0.1in;
  }

  .final-section h3 {
    margin-bottom: 4px;
    padding-bottom: 3px;
    font-size: 0.86rem;
  }

  .final-section li {
    margin-bottom: 2px;
    font-size: 0.66rem;
    line-height: 1.22;
  }

  .final-section li,
  .report-intro p {
    font-size: 0.66rem;
    line-height: 1.22;
  }

  .report-intro h3 {
    margin-bottom: 2px;
    font-size: 0.9rem;
  }

  @page {
    margin: 0;
  }

  @page chart {
    size: letter landscape;
    margin: 0;
  }

  @page profile {
    size: letter portrait;
    margin: 0;
  }
}
