.ps-survey-home-entry,
.ps-survey-list,
.ps-survey,
.ps-survey-results {
  display: grid;
  gap: 1rem;
  margin: 2rem 0;
}

.ps-survey-home-entry__head,
.ps-survey-list__head,
.ps-survey__header {
  display: grid;
  gap: 0.6rem;
}

.ps-survey-home-entry__head h2,
.ps-survey-list__head h2,
.ps-survey__header h2,
.ps-survey-results__section h3,
.ps-survey-results-card h3 {
  margin: 0;
}

.ps-survey-home-entry__head p,
.ps-survey-list__head p,
.ps-survey__summary,
.ps-survey__intro p,
.ps-survey-results__section p,
.ps-survey-results-card p {
  margin: 0;
}

.ps-survey-card-grid,
.ps-survey-results-grid,
.ps-survey-admin-detail__answers,
.ps-survey-segment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.ps-survey-card,
.ps-survey-question,
.ps-survey-results-card,
.ps-survey-segment,
.ps-survey-results__metric,
.ps-survey-flash,
.ps-survey-admin__question,
.ps-survey-admin-detail,
.ps-survey-admin__help {
  border: 1px solid rgba(23, 34, 51, 0.12);
  border-radius: 8px;
  background: rgba(154, 214, 244, 0.1);
}

.ps-survey-admin__question,
.ps-survey-admin-detail,
.ps-survey-admin__help {
  background: #fff;
}

.ps-survey-card,
.ps-survey-question,
.ps-survey-results-card,
.ps-survey-segment,
.ps-survey-admin-detail,
.ps-survey-admin__question {
  padding: 1rem;
}

.ps-survey-card {
  display: grid;
  gap: 0.75rem;
}

.ps-survey-card h3,
.ps-survey-question__head h3,
.ps-survey-results-card h3 {
  font-size: 1.05rem;
  line-height: 1.3;
}

.ps-survey-card__meta,
.ps-survey-question__head,
.ps-survey-form__actions,
.ps-survey-card__actions,
.ps-survey-results__summary,
.ps-survey-admin__question-head,
.ps-survey-admin__question-actions,
.ps-survey-admin__logic-head,
.ps-survey-admin__logic-group-head,
.ps-survey-admin-filter,
.ps-survey-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.ps-survey-card__meta span,
.ps-survey-required,
.ps-survey-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.8rem;
  padding: 0 0.6rem;
  border-radius: 999px;
  background: rgba(31, 91, 105, 0.08);
  color: #1f5b69;
  font-size: 0.78rem;
  font-weight: 700;
}

.ps-survey-required {
  background: rgba(191, 64, 48, 0.08);
  color: #bf4030;
}

.ps-survey-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 1px solid #1f5b69;
  border-radius: 8px;
  background: #1f5b69;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.ps-survey-button:hover,
.ps-survey-button:focus-visible {
  background: #184853;
  border-color: #184853;
  color: #fff;
}

.ps-survey-button--ghost {
  background: transparent;
  color: #1f5b69;
}

.ps-survey-button--ghost:hover,
.ps-survey-button--ghost:focus-visible {
  background: rgba(31, 91, 105, 0.08);
  color: #1f5b69;
}

.ps-survey-form,
.ps-survey-form__questions,
.ps-survey-results__section,
.ps-survey-admin__settings,
.ps-survey-admin__questions,
.ps-survey-admin-wrap {
  display: grid;
  gap: 1rem;
}

.ps-survey-question {
  display: grid;
  gap: 0.8rem;
}

.ps-survey-question.is-hidden {
  display: none;
}

.ps-survey-question.has-error {
  border-color: rgba(191, 64, 48, 0.32);
}

.ps-survey-question__help {
  color: #5b6472;
  font-size: 0.95rem;
}

.ps-survey-question__body {
  display: grid;
  gap: 0.7rem;
}

.ps-survey-choice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(23, 34, 51, 0.1);
  border-radius: 8px;
  background: rgba(154, 214, 244, 0.14);
}

.ps-survey-choice--compact {
  justify-content: center;
  min-width: 3.2rem;
}

.ps-survey-choice input {
  margin-top: 0.2rem;
}

.ps-survey-question textarea,
.ps-survey-question input[type="text"],
.ps-survey-question input[type="email"],
.ps-survey-question input[type="number"],
.ps-survey-question input[type="date"] {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid rgba(23, 34, 51, 0.12);
  border-radius: 8px;
  background: #fff;
  color: #172233;
}

.ps-survey-question textarea {
  min-height: 7rem;
  resize: vertical;
}

.ps-survey-rating {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(3.2rem, 1fr));
  gap: 0.55rem;
}

.ps-survey-rating__legend,
.ps-survey-contact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.ps-survey-contact-grid label {
  display: grid;
  gap: 0.4rem;
}

.ps-survey-results__summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.ps-survey-results__metric {
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
}

.ps-survey-segment {
  display: grid;
  gap: 1rem;
}

.ps-survey-segment__head {
  display: grid;
  gap: 0.8rem;
}

.ps-survey-segment__head h4 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
}

.ps-survey-results__metric span,
.ps-survey-stat-list dt,
.ps-survey-admin__checkbox span {
  color: #5b6472;
  font-size: 0.92rem;
}

.ps-survey-results__metric strong,
.ps-survey-stat-list dd {
  color: #172233;
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
}

.ps-survey-stat-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  margin: 0;
}

.ps-survey-stat-list div {
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(23, 34, 51, 0.08);
  border-radius: 8px;
  background: rgba(154, 214, 244, 0.12);
}

.ps-survey-distribution,
.ps-survey-trend {
  display: grid;
  gap: 0.55rem;
}

.ps-survey-distribution__row,
.ps-survey-trend__row {
  display: grid;
  grid-template-columns: minmax(0, 10rem) minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
}

.ps-survey-distribution__label,
.ps-survey-trend__label {
  font-size: 0.93rem;
  color: #172233;
}

.ps-survey-distribution__bar,
.ps-survey-trend__bar {
  display: block;
  height: 0.8rem;
  border-radius: 999px;
  background: rgba(23, 34, 51, 0.08);
  overflow: hidden;
}

.ps-survey-distribution__bar span,
.ps-survey-trend__bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1f5b69, #3d8a95);
}

.ps-survey-distribution__count,
.ps-survey-trend__count {
  font-weight: 700;
  color: #172233;
}

.ps-survey-flash {
  padding: 0.9rem 1rem;
}

.ps-survey-flash--success {
  border-color: rgba(28, 125, 82, 0.26);
  background: rgba(28, 125, 82, 0.08);
  color: #185d41;
}

.ps-survey-flash--error {
  border-color: rgba(191, 64, 48, 0.26);
  background: rgba(191, 64, 48, 0.08);
  color: #8b2f23;
}

.ps-survey-admin__help {
  padding: 0.85rem 1rem;
}

.ps-survey-admin__settings-grid,
.ps-survey-admin__question-grid,
.ps-survey-admin__subsection--grid,
.ps-survey-admin__option,
.ps-survey-admin__condition {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.ps-survey-admin__settings-grid label,
.ps-survey-admin__question-grid label,
.ps-survey-admin__subsection--grid label {
  display: grid;
  gap: 0.35rem;
}

.ps-survey-admin__settings-grid textarea,
.ps-survey-admin__question-grid textarea,
.ps-survey-admin__question-grid input[type="text"],
.ps-survey-admin__question-grid select,
.ps-survey-admin__subsection input,
.ps-survey-admin__subsection textarea,
.ps-survey-admin__subsection select,
.ps-survey-admin-filter select {
  width: 100%;
  min-height: 2.6rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid rgba(23, 34, 51, 0.14);
  border-radius: 8px;
  background: #fff;
}

.ps-survey-admin__settings-grid textarea,
.ps-survey-admin__question-grid textarea {
  min-height: 6rem;
  resize: vertical;
}

.ps-survey-admin__checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.ps-survey-admin__subsection {
  display: grid;
  gap: 0.7rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(23, 34, 51, 0.08);
}

.ps-survey-admin__subsection h4,
.ps-survey-admin__logic-group h4 {
  margin: 0;
  font-size: 0.98rem;
}

.ps-survey-admin__logic-group,
.ps-survey-admin-detail__answers .ps-survey-results-card {
  display: grid;
  gap: 0.7rem;
}

.ps-survey-admin__logic-group {
  padding: 0.9rem;
  border: 1px solid rgba(23, 34, 51, 0.08);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.72);
}

.ps-survey-admin__logic-conditions,
.ps-survey-admin-text-list {
  display: grid;
  gap: 0.6rem;
}

.ps-survey-admin-text-list,
.ps-survey-admin-detail__answers ul {
  margin: 0;
  padding-left: 1.15rem;
}

.ps-survey-admin-filter label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.ps-survey-admin-actions {
  margin: 1rem 0;
}

.ps-survey-admin-detail {
  margin: 1rem 0 0;
  display: grid;
  gap: 1rem;
}

@media (max-width: 960px) {
  .ps-survey-card-grid,
  .ps-survey-results-grid,
  .ps-survey-admin-detail__answers,
  .ps-survey-segment-grid,
  .ps-survey-results__summary,
  .ps-survey-stat-list,
  .ps-survey-contact-grid,
  .ps-survey-rating__legend,
  .ps-survey-admin__settings-grid,
  .ps-survey-admin__question-grid,
  .ps-survey-admin__subsection--grid,
  .ps-survey-admin__option,
  .ps-survey-admin__condition {
    grid-template-columns: 1fr;
  }

  .ps-survey-distribution__row,
  .ps-survey-trend__row {
    grid-template-columns: 1fr;
  }
}

/* ── Progress bar ── */
.ps-survey-progress {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(23, 34, 51, 0.08);
}
.ps-survey-progress__track {
  height: 6px;
  border-radius: 999px;
  background: rgba(23, 34, 51, 0.08);
  overflow: hidden;
}
.ps-survey-progress__fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1f5b69, #3d8a95, #5bb8a9);
  transition: width 0.45s cubic-bezier(0.25, 0.8, 0.25, 1);
  width: 0;
}
.ps-survey-progress__label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #5b6472;
  margin-top: 0.35rem;
}

/* ── Card hover ── */
.ps-survey-card {
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
.ps-survey-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(23, 34, 51, 0.1);
}

/* ── Choice selection states ── */
.ps-survey-choice {
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.15s ease;
  cursor: pointer;
}
.ps-survey-choice:hover {
  border-color: rgba(31, 91, 105, 0.28);
  background: rgba(154, 214, 244, 0.2);
}
.ps-survey-choice.is-selected {
  border-color: #1f5b69;
  background: rgba(154, 214, 244, 0.24);
  transform: scale(1.015);
}
.ps-survey-choice.is-selected::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: #1f5b69;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-right: -0.3rem;
}

/* ── Rating stars ── */
.ps-survey-choice--compact {
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.ps-survey-choice--compact:hover {
  transform: scale(1.12);
  border-color: rgba(31, 91, 105, 0.3);
}
.ps-survey-choice--compact.is-selected {
  background: linear-gradient(135deg, #1f5b69 0%, #3d8a95 100%);
  border-color: #1f5b69;
  color: #fff;
  transform: scale(1.12);
}
.ps-survey-choice--compact.is-selected span {
  color: #fff;
  font-weight: 700;
}

/* ── Submit button states ── */
.ps-survey-button {
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  position: relative;
}
.ps-survey-button:active {
  transform: scale(0.97);
}
.ps-survey-button.is-loading {
  pointer-events: none;
  opacity: 0.78;
}
.ps-survey-button.is-loading::after {
  content: "";
  display: inline-block;
  width: 1rem;
  height: 1rem;
  margin-left: 0.5rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ps-spin 0.6s linear infinite;
}
@keyframes ps-spin {
  to { transform: rotate(360deg); }
}

/* ── Toast / Flash animations ── */
.ps-survey-flash {
  animation: ps-toast-in 0.4s ease-out;
  transition: opacity 0.5s ease, transform 0.5s ease;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.ps-survey-flash--success::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: rgba(28, 125, 82, 0.18);
  color: #185d41;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}
.ps-survey-flash--error::before {
  content: "!";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: rgba(191, 64, 48, 0.18);
  color: #8b2f23;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}
.ps-survey-flash.is-fading {
  opacity: 0;
  transform: translateY(-12px);
}
@keyframes ps-toast-in {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Distribution bar animation ── */
.ps-survey-distribution__bar span,
.ps-survey-trend__bar span {
  animation: ps-bar-grow 0.7s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}
@keyframes ps-bar-grow {
  from { transform: scaleX(0); transform-origin: left; }
  to   { transform: scaleX(1); transform-origin: left; }
}

/* ── Results metric counter animation ── */
.ps-survey-results__metric strong {
  display: inline-block;
}

/* ── Question entrance animation ── */
.ps-survey-question {
  animation: ps-fade-up 0.35s ease-out both;
}
@keyframes ps-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ps-survey-question:nth-child(2) { animation-delay: 0.05s; }
.ps-survey-question:nth-child(3) { animation-delay: 0.10s; }
.ps-survey-question:nth-child(4) { animation-delay: 0.15s; }
.ps-survey-question:nth-child(5) { animation-delay: 0.20s; }
.ps-survey-question:nth-child(6) { animation-delay: 0.25s; }

/* ── Smooth scroll target highlight ── */
.ps-survey-question.has-error {
  animation: ps-shake 0.4s ease;
}
@keyframes ps-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* ── Results card hover ── */
.ps-survey-results-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ps-survey-results-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(23, 34, 51, 0.08);
}

/* ── Badge pulse for active status ── */
.ps-survey-badge--active {
  background: rgba(28, 125, 82, 0.1);
  color: #185d41;
  position: relative;
}
.ps-survey-badge--active::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.35rem;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1c7d52;
  transform: translateY(-50%);
  animation: ps-pulse 2s ease-in-out infinite;
}
.ps-survey-badge--active {
  padding-left: 1.1rem;
}
@keyframes ps-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ── Dark mode ── */
@media (prefers-color-scheme: dark) {
  .ps-survey-card,
  .ps-survey-question,
  .ps-survey-results-card,
  .ps-survey-results__metric,
  .ps-survey-flash,
  .ps-survey-admin__help {
    border-color: rgba(255, 255, 255, 0.1);
    background: #1e2330;
    color: #e0e4ea;
  }
  .ps-survey-choice {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
  }
  .ps-survey-choice:hover {
    border-color: rgba(93, 184, 169, 0.3);
    background: rgba(93, 184, 169, 0.06);
  }
  .ps-survey-choice.is-selected {
    border-color: #5bb8a9;
    background: rgba(93, 184, 169, 0.12);
  }
  .ps-survey-choice.is-selected::before {
    background: #5bb8a9;
  }
  .ps-survey-question textarea,
  .ps-survey-question input[type="text"],
  .ps-survey-question input[type="email"],
  .ps-survey-question input[type="number"],
  .ps-survey-question input[type="date"] {
    background: #161a24;
    border-color: rgba(255, 255, 255, 0.1);
    color: #e0e4ea;
  }
  .ps-survey-button {
    background: #3d8a95;
    border-color: #3d8a95;
  }
  .ps-survey-button:hover,
  .ps-survey-button:focus-visible {
    background: #5bb8a9;
    border-color: #5bb8a9;
  }
  .ps-survey-button--ghost {
    background: transparent;
    color: #5bb8a9;
    border-color: #5bb8a9;
  }
  .ps-survey-progress {
    background: rgba(30, 35, 48, 0.92);
    border-color: rgba(255, 255, 255, 0.06);
  }
  .ps-survey-progress__track {
    background: rgba(255, 255, 255, 0.08);
  }
  .ps-survey-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  }
  .ps-survey-required {
    background: rgba(255, 100, 80, 0.12);
    color: #ff8a75;
  }
  .ps-survey-badge {
    background: rgba(93, 184, 169, 0.12);
    color: #5bb8a9;
  }
  .ps-survey-results__metric span,
  .ps-survey-question__help,
  .ps-survey-progress__label {
    color: #8a90a0;
  }
  .ps-survey-results__metric strong,
  .ps-survey-distribution__count,
  .ps-survey-trend__count {
    color: #e0e4ea;
  }
  .ps-survey-distribution__bar,
  .ps-survey-trend__bar {
    background: rgba(255, 255, 255, 0.06);
  }
  .ps-survey-flash--success {
    border-color: rgba(28, 125, 82, 0.3);
    background: rgba(28, 125, 82, 0.12);
    color: #6ee7a8;
  }
  .ps-survey-flash--error {
    border-color: rgba(255, 100, 80, 0.3);
    background: rgba(255, 100, 80, 0.1);
    color: #ff8a75;
  }
  .ps-survey-stat-list div {
    border-color: rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
  }
  .ps-survey-choice--compact.is-selected {
    background: linear-gradient(135deg, #3d8a95 0%, #5bb8a9 100%);
    border-color: #5bb8a9;
  }
}
