:root {
  color-scheme: light;
  --ink: #242629;
  --muted: #6b7078;
  --line: #d9dde2;
  --panel: #ffffff;
  --page: #f5f2ed;
  --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:
    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;
}

button,
input {
  font: inherit;
}

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

.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-size: clamp(1.85rem, 4vw, 3rem);
  line-height: 1.08;
  letter-spacing: 0;
}

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

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

.person-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
  background: #fff7e6;
  border: 1px solid #f0d7a8;
  border-radius: 8px;
}

.name-field {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid #e5c78f;
  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: #f4d88f;
  color: #59420f;
  font-size: 0.67rem;
  font-style: normal;
  text-transform: uppercase;
}

.name-field input {
  width: 100%;
  height: 44px;
  padding: 8px 12px;
  border: 1px solid #bcc3cc;
  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: 14px;
}

.question-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.question-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 750;
}

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

.rank-item {
  display: grid;
  grid-template-columns: 36px 1fr 78px;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid #cfd5dc;
  border-radius: 7px;
  background: #fbfcfd;
}

.rank-item[draggable="true"] {
  cursor: grab;
}

.rank-item.dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.rank-number {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #e9edf1;
  color: #40464d;
  font-weight: 750;
  font-size: 0.85rem;
}

.rank-text {
  min-width: 0;
}

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

.icon-button {
  width: 34px;
  height: 32px;
  border: 1px solid #c8ced6;
  border-radius: 6px;
  background: #fff;
  color: #38414a;
  cursor: pointer;
}

.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;
}

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

.screen-actions {
  margin-bottom: 14px;
}

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

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

.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);
}

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

.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;
}

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

.choice-toggle {
  position: relative;
  width: 52px;
  min-width: 52px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: #c8cdd3;
  cursor: pointer;
  transition: background 160ms ease;
}

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

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.24);
  transition: transform 160ms ease;
}

.choice-toggle[aria-pressed="true"] .toggle-knob {
  transform: translateX(22px);
}

.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.48in;
  background: #fff;
  border: 1px solid #e0ddd6;
  box-shadow: 0 18px 50px rgb(59 54 45 / 0.1);
}

.pdf-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ebe6de;
}

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

.pdf-header > p {
  margin: 0;
  color: var(--muted);
  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: 14px;
  padding: 11px 12px;
  background: var(--soft);
  border-left: 4px solid var(--accent);
}

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

.final-charts {
  display: grid;
  gap: 9px;
  margin-bottom: 12px;
}

.final-chart-panel {
  border: 1px solid #e3ded5;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfaf7 100%);
  padding: 7px;
}

.final-chart-panel h3 {
  margin-bottom: 6px;
  color: #62676e;
  font-size: 0.72rem;
  font-weight: 750;
  text-transform: uppercase;
}

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

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

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

.final-pie-grid .final-chart-panel {
  aspect-ratio: 1;
}

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

.final-section h3 {
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #ebe6de;
  color: #4f5963;
  font-size: 0.98rem;
}

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

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

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

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

  .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 {
    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.32in 0.36in;
    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.25rem;
  }

  .pdf-header {
    margin-bottom: 8px;
    padding-bottom: 6px;
  }

  .final-charts {
    gap: 7px;
    margin-bottom: 8px;
  }

  .final-chart-panel {
    padding: 5px;
    border-radius: 6px;
  }

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

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

  .final-pie-grid {
    gap: 6px;
  }

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

  .final-section-grid {
    column-gap: 18px;
    row-gap: 8px;
  }

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

  .final-section li {
    margin-bottom: 3px;
    font-size: 0.78rem;
    line-height: 1.3;
  }

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

  .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;
  }
}
