:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #18202b;
  --muted: #667085;
  --line: #d7dde5;
  --primary: #2e2340;
  --primary-dark: #1d1629;
  --accent: #f28d2c;
  --brand-orange: #f28d2c;
  --warning-bg: #fff7ed;
  --warning-line: #fed7aa;
  --shadow: 0 14px 38px rgba(24, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button {
  font: inherit;
  max-width: 100%;
  white-space: normal;
}

a {
  color: inherit;
}

.survey-shell {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 12px;
}

.app {
  min-height: calc(100dvh - 24px);
}

.funding-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  padding: 28px 0 12px;
}

.funding-logo {
  display: block;
  width: 200px;
  max-width: 100%;
  height: auto;
}

.question-view,
.feedback-view {
  padding-bottom: 92px;
}

.survey-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.survey-header h1 {
  margin: 0;
  color: var(--primary);
  font-size: 1.55rem;
  line-height: 1.15;
}

.survey-logo {
  display: block;
  width: 172px;
  height: auto;
  margin-bottom: 12px;
}

.questionnaire-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.questionnaire-header .survey-logo {
  margin: 0;
}

.questionnaire-header h1 {
  text-align: right;
  overflow-wrap: anywhere;
}

.questionnaire-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 14px;
  margin-bottom: 14px;
}

.questionnaire-toolbar .progress-block {
  min-width: 0;
  margin: 0;
}

.questionnaire-toolbar .ghost-button {
  min-width: 118px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.access-view,
.status-view {
  width: 100%;
}

.form-panel,
.status-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.access-form,
.form-field {
  display: grid;
  gap: 8px;
}

.access-form {
  gap: 18px;
}

.form-error {
  margin: 0;
  color: #9b1c1c;
  font-weight: 700;
}

.form-field label {
  font-weight: 700;
}

.form-field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.form-field input:focus,
.feedback-field textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(46, 35, 64, 0.18);
}

.field-hint,
.status-panel p {
  margin: 0;
  color: var(--muted);
}

.status-panel h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  text-decoration: none;
}

.response-token {
  display: grid;
  gap: 3px;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.response-token span {
  color: var(--muted);
  font-size: 0.86rem;
}

.response-token strong {
  font-size: 1.2rem;
  letter-spacing: 0.06em;
}

.progress-block {
  margin-bottom: 14px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  background: #e6eaf0;
  border-radius: 999px;
}

.progress-track span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 180ms ease;
}

.question-card {
  padding: 18px;
}

.position-panel,
.feedback-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.position-panel h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
}

.target-person {
  margin: 0;
  color: var(--muted);
}

.target-person strong {
  color: var(--ink);
}

.position-options {
  display: grid;
  gap: 10px;
}

.choice-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  width: 100%;
  padding: 12px 14px;
  color: var(--ink);
  text-align: left;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.choice-card:hover,
.choice-card:focus-visible {
  border-color: var(--primary);
  outline: none;
}

.choice-card.selected {
  color: var(--primary-dark);
  background: #f4f1f7;
  border-color: var(--primary);
}

.choice-card.selected .answer-dot {
  border: 6px solid var(--primary);
  background: #ffffff;
}

.question-meta {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.question-meta span:first-child {
  color: var(--primary-dark);
  font-weight: 700;
}

.question-card h2 {
  margin: 0 0 18px;
  font-size: 1.35rem;
  line-height: 1.25;
}

.answers {
  display: grid;
  gap: 10px;
}

.answer-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  color: var(--ink);
  text-align: left;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-left: 6px solid var(--tone, var(--line));
  border-radius: 8px;
  cursor: pointer;
}

.answer-option:hover,
.answer-option:focus-visible {
  border-color: var(--tone, var(--primary));
  outline: none;
}

.answer-option.selected {
  border-color: var(--tone, var(--primary));
  background: var(--tone-bg, #eef4ff);
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--tone, var(--primary));
}

.answer-dot {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border: 2px solid #98a2b3;
  border-radius: 50%;
}

.answer-option.selected .answer-dot {
  border: 6px solid var(--tone, var(--primary));
  background: #ffffff;
}

.answer-option.tone-1 {
  --tone: #d92d20;
  --tone-bg: #fff1f0;
}

.answer-option.tone-2 {
  --tone: #f59c76;
  --tone-bg: #fff4ee;
}

.answer-option.tone-3 {
  --tone: #7a8494;
  --tone-bg: #f1f3f5;
}

.answer-option.tone-4 {
  --tone: #8bcf3f;
  --tone-bg: #f0fbe7;
}

.answer-option.tone-5 {
  --tone: #2f9e44;
  --tone-bg: #eaf8ed;
}

.question-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px -12px -12px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: rgba(244, 245, 247, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.action-stack {
  display: contents;
}

.summary-buttons {
  display: grid;
  gap: 10px;
}

.question-actions [data-action="next"],
.question-actions [data-action="summary"] {
  order: 1;
}

.question-actions [data-action="skip"],
.question-actions [data-action="position"] {
  order: 2;
}

.question-actions [data-action="previous"] {
  order: 3;
}

.full-width {
  width: 100%;
}

.two-actions {
  grid-template-columns: 1fr;
}

.primary-button,
.secondary-button,
.ghost-button,
.text-button,
.icon-button {
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  color: #ffffff;
  background: var(--primary);
  border: 1px solid var(--primary);
  font-weight: 700;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.secondary-button,
.ghost-button {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  font-weight: 700;
}

.ghost-button {
  min-height: 38px;
  padding: 0 12px;
}

.text-button {
  color: var(--primary);
  background: transparent;
  border: 0;
  font-weight: 700;
}

.icon-button {
  min-width: 126px;
  padding: 0 12px;
  color: var(--primary);
  background: #ffffff;
  border: 1px solid var(--line);
  font-weight: 700;
}

button:disabled,
button:disabled:hover,
button:disabled:focus-visible {
  color: #7d8590 !important;
  background: #e7eaee !important;
  border-color: #d2d7de !important;
  box-shadow: none !important;
  cursor: not-allowed;
  opacity: 1;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.summary-stats div {
  display: grid;
  gap: 2px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-stats strong {
  font-size: 1.35rem;
  line-height: 1;
}

.summary-stats span {
  color: var(--muted);
  font-size: 0.82rem;
}

.summary-controls {
  display: grid;
  gap: 12px;
  padding: 12px;
  margin-bottom: 18px;
}

.summary-submit-bottom {
  margin-top: 18px;
  margin-bottom: 0;
}

.summary-filter-row {
  display: flex;
  margin: -2px 0 14px;
}

.filter-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.filter-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.switch-control {
  display: inline-flex;
  flex: 0 0 48px;
  align-items: center;
  width: 48px;
  height: 28px;
  padding: 3px;
  background: #c8ced7;
  border-radius: 999px;
  transition: background 160ms ease;
}

.switch-control span {
  width: 22px;
  height: 22px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(24, 32, 43, 0.28);
  transition: transform 160ms ease;
}

.filter-switch input:checked + .switch-control {
  background: var(--primary);
}

.filter-switch input:checked + .switch-control span {
  transform: translateX(20px);
}

.filter-switch input:focus-visible + .switch-control {
  outline: 3px solid rgba(46, 35, 64, 0.24);
  outline-offset: 2px;
}

.summary-group {
  margin-bottom: 22px;
}

.summary-group h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.summary-items {
  display: grid;
  gap: 8px;
}

.summary-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-item.skipped {
  background: var(--warning-bg);
  border-color: var(--warning-line);
}

.summary-item.not-applicable {
  background: #f8fafc;
  border-style: dashed;
}

.summary-item.feedback-summary {
  align-items: start;
}

.summary-question,
.summary-answer {
  margin: 0;
}

.summary-question {
  font-weight: 700;
}

.summary-answer {
  color: var(--muted);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 18px;
}

.empty-state h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}

.empty-state p,
.muted {
  margin: 0;
  color: var(--muted);
}

.feedback-field {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

.feedback-field textarea {
  width: 100%;
  min-height: 148px;
  resize: vertical;
  padding: 12px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-weight: 400;
}

.feedback-field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.feedback-field textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(46, 35, 64, 0.18);
}

@media (min-width: 720px) {
  .survey-shell {
    padding: 28px;
  }

  .app {
    min-height: calc(100vh - 56px);
  }

  .question-view,
  .feedback-view {
    padding-bottom: 0;
  }

  .question-card {
    padding: 28px;
  }

  .position-panel,
  .feedback-panel {
    padding: 28px;
  }

  .position-options {
    grid-template-columns: repeat(2, 1fr);
  }

  .question-card h2 {
    font-size: 1.65rem;
  }

  .question-actions {
    position: static;
    display: grid;
    grid-template-columns: 160px 1fr;
    align-items: end;
    margin: 16px 0 0;
    padding: 0;
    background: transparent;
    border-top: 0;
    backdrop-filter: none;
  }

  .action-stack {
    display: grid;
    grid-template-columns: 1fr 140px 180px;
    align-items: center;
    gap: 10px;
  }

  .question-actions [data-action="next"],
  .question-actions [data-action="summary"],
  .question-actions [data-action="skip"],
  .question-actions [data-action="position"],
  .question-actions [data-action="previous"] {
    order: 0;
  }

  .two-actions {
    grid-template-columns: 1fr 180px;
  }

  .summary-controls {
    display: block;
  }

  .summary-buttons {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .form-panel,
  .status-panel {
    padding: 28px;
  }
}

@media (max-width: 480px) {
  .survey-shell {
    padding: 10px;
  }

  .app {
    min-height: calc(100dvh - 20px);
  }

  .question-view,
  .feedback-view {
    padding-bottom: 112px;
  }

  .survey-header {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
  }

  .survey-header > div {
    flex: 1 1 210px;
    min-width: 0;
  }

  .survey-header h1 {
    font-size: 1.55rem;
    overflow-wrap: anywhere;
  }

  .survey-logo {
    width: 150px;
    margin-bottom: 10px;
  }

  .questionnaire-header {
    grid-template-columns: 135px minmax(0, 1fr);
    gap: 10px;
  }

  .questionnaire-header .survey-logo {
    width: 135px;
    margin: 0;
  }

  .questionnaire-header h1 {
    font-size: 1.15rem;
  }

  .questionnaire-toolbar {
    gap: 10px;
  }

  .questionnaire-toolbar .ghost-button {
    min-width: auto;
  }

  .survey-header .eyebrow,
  .question-meta {
    font-size: 0.94rem;
  }

  .ghost-button {
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.92rem;
  }

  .position-panel,
  .feedback-panel,
  .question-card {
    padding: 16px;
  }

  .position-panel h2,
  .question-card h2 {
    font-size: 1.22rem;
  }

  .question-actions {
    margin: 14px -10px -10px;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .text-button,
  .icon-button,
  .answer-option,
  .choice-card {
    min-height: 46px;
  }

  .summary-stats {
    gap: 6px;
  }

  .summary-view .summary-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .summary-view .summary-stats div:last-child {
    grid-column: 1 / -1;
  }

  .summary-stats div {
    padding: 10px 8px;
  }

  .summary-stats strong {
    font-size: 1.18rem;
  }

  .summary-stats span {
    font-size: 0.78rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .summary-item {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .icon-button {
    width: 100%;
  }
}

@media (max-width: 340px) {
  .survey-shell {
    padding: 8px;
  }

  .survey-header h1 {
    font-size: 1.24rem;
  }

  .position-panel,
  .feedback-panel,
  .question-card {
    padding: 14px;
  }

  .position-panel h2,
  .question-card h2 {
    font-size: 1.12rem;
  }

  .answer-option,
  .choice-card {
    gap: 10px;
    padding: 10px 12px;
  }

  .question-actions {
    margin: 12px -8px -8px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }
}
