:root {
  --font-family:
    "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --primary-color: #6366f1;
  --bg-color: #f8fafc;
  --card-bg-color: #fff;
  --text-color: #1e293b;
  --text-color-secondary: rgba(100, 116, 139, 0.7);
  --input-bg-color: #f8fafc;
  --border-color: #e2e8f0;

  /* Fallback variables for color-mix */
  --primary-color-light-10: rgba(99, 102, 241, 0.1);
  --primary-color-light-15: rgba(99, 102, 241, 0.15);
  --primary-color-light-20: rgba(99, 102, 241, 0.2);
  --primary-color-dark-80: rgb(79, 82, 193);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 80px 15px 50px;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.is-exporting .survey-header-top,
body.is-exporting .jump-grid-container,
body.is-exporting .form-actions,
body.is-exporting .page-footer {
  display: none !important;
}

.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.75rem;
  font-size: 1.05rem;
  font-weight: 500;
  border-radius: 9999px;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
}

.primary-btn .icon-right,
.secondary-btn .icon-right {
  margin-left: 0.5rem;
  transition: transform 0.3s ease;
}

.primary-btn:hover:not(:disabled) .icon-right,
.secondary-btn:hover:not(:disabled) .icon-right {
  transform: translateX(3px);
}

.primary-btn {
  background-image: linear-gradient(
    to right,
    var(--primary-color) 0%,
    color-mix(in srgb, var(--primary-color) 80%, #8b5cf6) 51%,
    var(--primary-color) 100%
  );
  background-size: 200% auto;
  color: #fff;
  box-shadow: 0 4px 15px 0
    color-mix(in srgb, var(--primary-color) 25%, transparent);
}

.primary-btn:hover:not(:disabled) {
  background-position: right center;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px 0
    color-mix(in srgb, var(--primary-color) 35%, transparent);
}

.secondary-btn {
  background-color: var(--card-bg-color);
  color: var(--primary-color);
  border-color: var(--border-color);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.secondary-btn:hover:not(:disabled) {
  background-color: var(--primary-color-light-10);
  background-color: color-mix(
    in srgb,
    var(--primary-color) 10%,
    var(--card-bg-color)
  );
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.primary-btn:active:not(:disabled),
.secondary-btn:active:not(:disabled) {
  transform: translateY(0);
}

.primary-btn:disabled,
.secondary-btn:disabled {
  background-image: none;
  background-color: #e2e8f0;
  color: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
}

.survey-page-container {
  width: 100%;
}
.survey-main-content-wrapper {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-left: auto;
  margin-right: auto;
  padding-right: 20px;
}

.section-card {
  position: relative;
  background-color: var(--card-bg-color);
  width: 100%;
  border-radius: 1.5rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 30px
    color-mix(in srgb, var(--primary-color) 8%, transparent);
  overflow: hidden;
}

.survey-container {
  padding: 40px 50px 50px;
  text-align: center;
  margin-top: 20px;
}
.page-footer {
  text-align: center;
  margin-top: 40px;
  padding: 30px 40px;
  margin-bottom: 50px;
}

.survey-header-top {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background: color-mix(in srgb, var(--card-bg-color) 85%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  padding: 8px 20px;
  flex-wrap: wrap;
}

.home-button {
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  margin-right: auto;
  white-space: nowrap;
}
.progress-bar-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-grow: 1;
  max-width: 600px;
  margin: 0 auto;
}

progress#scrollProgress {
  flex-grow: 1;
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background-color: var(--primary-color-light-10);
  background-color: color-mix(in srgb, var(--primary-color) 10%, transparent);
  border-radius: 5px;
  overflow: hidden;
}
progress#scrollProgress::-webkit-progress-bar {
  background-color: transparent;
}
progress#scrollProgress::-webkit-progress-value {
  background: var(--primary-color);
  border-radius: 5px;
  transition: width 0.3s ease-out;
}
.counter {
  color: var(--text-color-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.jump-grid-container {
  position: fixed;
  top: 100px;
  right: 100px;
  z-index: 990;
  background-color: var(--card-bg-color);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
  width: 375px;
  padding: 15px;
}
.jump-grid-header h3 {
  font-size: 1.1rem;
  color: var(--primary-color);
  margin: 0;
}
.jump-grid-toggle {
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-color-secondary);
  padding: 5px;
  transition: transform 0.2s ease;
}
.jump-grid-container.collapsed .jump-grid {
  display: none;
}
.jump-grid-container.collapsed .jump-grid-toggle {
  transform: rotate(180deg);
}
.jump-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 6px;
}
.grid-cell {
  width: 28px;
  height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-color-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.grid-cell:hover:not(.current):not(.inactive) {
  background-color: var(--primary-color-light-10);
  border-color: var(--primary-color-light-30);
  background-color: color-mix(in srgb, var(--primary-color) 10%, transparent);
  border-color: color-mix(in srgb, var(--primary-color) 30%, transparent);
  transform: translateY(-1px);
}
.grid-cell.filled {
  background-color: var(--primary-color-light-15);
  border-color: var(--primary-color-light-30);
  background-color: color-mix(in srgb, var(--primary-color) 15%, transparent);
  border-color: color-mix(in srgb, var(--primary-color) 50%, transparent);
  color: var(--primary-color);
  font-weight: 700;
}
.grid-cell.current {
  background-color: var(--primary-color);
  border-color: var(--primary-color-dark-80);
  border-color: color-mix(in srgb, var(--primary-color) 80%, black);
  color: white;
  font-weight: 700;
  transform: scale(1.1);
  box-shadow: 0 2px 8px
    color-mix(in srgb, var(--primary-color) 40%, transparent);
  z-index: 1;
}
.grid-cell.inactive {
  background-color: color-mix(in srgb, var(--border-color) 50%, transparent);
  color: #cbd5e1;
  cursor: not-allowed;
}

.section-title,
h1 {
  font-weight: 700;
  font-size: 2.25rem;
  margin-bottom: 1rem;
  background-image: linear-gradient(
    120deg,
    var(--primary-color),
    color-mix(in srgb, var(--primary-color) 80%, #8b5cf6)
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.section-subtitle,
.subtitle {
  font-size: 1.125rem;
  color: var(--text-color-secondary);
  margin-bottom: 40px;
  line-height: 1.7;
}
.loading-message {
  text-align: center;
  color: var(--text-color-secondary);
  font-size: 1.1rem;
  padding: 50px 0;
}

legend {
  padding: 0 20px;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--primary-color);
  margin: 25px auto;
}
fieldset {
  border: none;
  padding: 0;
  margin: 0 0 35px 0;
  border-top: 1px solid color-mix(in srgb, var(--border-color) 50%, transparent);
}
fieldset:first-of-type {
  border-top: none;
}
.question-block {
  margin-bottom: 30px;
  text-align: left;
}
.question-block label {
  display: flex;
  align-items: flex-start;
  margin-bottom: 12px;
  font-weight: 500;
  color: var(--text-color);
  line-height: 1.6;
}
.question-number {
  font-weight: 700;
  color: var(--primary-color);
  margin-right: 8px;
}
.question-text {
  opacity: 0;
  white-space: pre-wrap;
}

input[type="text"],
input[type="number"],
input[type="email"],
textarea,
select {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-color);
  background-color: var(--input-bg-color);
  transition: all 0.3s ease;
}
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px var(--primary-color-light-20);
  box-shadow: 0 0 0 4px
    color-mix(in srgb, var(--primary-color) 20%, transparent);
  background-color: var(--card-bg-color);
}

.email-capture-block {
  text-align: left;
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid var(--border-color);
}
.email-label {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 8px;
  display: block;
}
.email-description {
  font-size: 0.9rem;
  color: var(--text-color-secondary);
  margin-bottom: 15px;
  line-height: 1.6;
}
.error-message {
  color: #dc2626;
  font-size: 0.875rem;
  margin-top: 8px;
  min-height: 1.25em;
  display: none;
}
input.input-error {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.2) !important;
}

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

.radio-group input[type="radio"]:checked + .radio-label {
  background-color: var(--primary-color-light-15);
  background-color: color-mix(in srgb, var(--primary-color) 15%, transparent);
  border-color: var(--primary-color);
  color: var(--primary-color);
  font-weight: 700;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--primary-color-light-15);
  box-shadow: 0 4px 12px
    color-mix(in srgb, var(--primary-color) 15%, transparent);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--primary-color);
  cursor: pointer;
  border-radius: 50%;
  border: 3px solid var(--card-bg-color);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}
.range-value-display {
  color: var(--primary-color);
}

.history-lookup .section-title-small {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}
.history-lookup .section-subtitle-small {
  font-size: 0.9rem;
  color: var(--text-color-secondary);
  margin-bottom: 1rem;
}
.history-input-group {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}
#historyLookupInput {
  flex-grow: 1;
  padding: 0.75rem 4rem 0.75rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  border-color: var(--border-color);
}
#clearLookupBtn {
  position: absolute;
  right: 65px;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1.1rem;
  transition: color 0.2s;
}
#clearLookupBtn:hover {
  color: var(--primary-color);
}
#clearLookupBtn.hidden {
  display: none;
}
#lookupBtn {
  position: absolute;
  right: 5px;
  width: 55px;
  height: calc(100% - 10px);
  margin: 5px 0;
  border-radius: 6px;
  background-color: var(--primary-color);
  color: white;
  border: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
#lookupBtn:hover:not(:disabled) {
  background-color: var(--primary-color-dark-80);
  background-color: color-mix(in srgb, var(--primary-color) 80%, black);
}
#lookupBtn:disabled {
  background-color: color-mix(in srgb, var(--primary-color) 50%, white);
  cursor: not-allowed;
}

.lookup-message {
  font-size: 0.875rem;
  margin-top: 0.75rem;
  min-height: 1.25em;
  text-align: left;
  transition: color 0.3s;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}
.lookup-message.success {
  color: #16a34a;
}
.lookup-message.error {
  color: #dc2626;
}

.footer-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--text-color-secondary);
}
.footer-links a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}
.footer-links a:hover {
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.6);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}
.modal-overlay.show {
  display: flex;
}
.modal-content {
  background-color: var(--card-bg-color);
  padding: 30px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 400px;
  text-align: center;
}
.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-color);
  margin-bottom: 15px;
}
.modal-text {
  font-size: 1rem;
  color: var(--text-color-secondary);
  line-height: 1.6;
  margin-bottom: 30px;
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 15px;
}
.modal-button {
  flex-grow: 1;
}

@media (max-width: 1200px) {
  .survey-main-content-wrapper {
    margin-right: 300px;
  }
}
@media (max-width: 992px) {
  .jump-grid-container {
    display: none;
  }
  .survey-main-content-wrapper {
    margin-right: auto;
    padding-right: 0;
  }
}
@media (max-width: 768px) {
  body {
    padding: 90px 10px 30px;
  }
  .survey-header-top {
    flex-direction: column;
    align-items: center;
    padding: 5px 10px;
  }
  .home-button {
    font-size: 0.9rem;
    margin: 0 0 8px 0;
    order: 1;
    padding: 0.5rem 1.2rem;
  }
  .progress-bar-container {
    flex-direction: column;
    gap: 5px;
    order: 2;
    width: 100%;
    max-width: unset;
  }
  .survey-container,
  .page-footer {
    padding: 25px 20px;
    border-radius: 20px;
  }
  .section-title,
  h1 {
    font-size: 1.8rem;
  }
  .section-subtitle,
  .subtitle {
    font-size: 1rem;
    margin-bottom: 30px;
  }
  .modal-actions {
    flex-direction: column;
    gap: 10px;
  }
}

.jump-grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.card-title-group {
  text-align: center;
}
fieldset.is-visible {
  opacity: 1;
  transform: translateY(0);
}
fieldset {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 0.6s ease-out,
    transform 0.6s ease-out;
}
.question-block.highlight-temp {
  animation: highlightFade 1.5s ease-out forwards;
  padding: 10px;
  margin: 0 0 30px 0;
  border-radius: 12px;
  background-color: var(--primary-color-light-10);
  background-color: color-mix(in srgb, var(--primary-color) 5%, transparent);
}
@keyframes highlightFade {
  from {
    background-color: var(--primary-color-light-10);
    background-color: color-mix(in srgb, var(--primary-color) 10%, transparent);
  }
  to {
    background-color: transparent;
  }
}
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 16px 12px;
}
.radio-group {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}
.radio-group input[type="radio"] {
  display: none;
}
.radio-group .radio-label {
  flex-grow: 1;
  padding: 13px 15px;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  background-color: var(--input-bg-color);
  font-weight: 500;
  min-width: 80px;
}
.other-text-input {
  flex-grow: 1;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  visibility: hidden;
}
.other-text-input.show {
  max-height: 100px;
  opacity: 1;
  margin-top: 10px;
  padding-top: 13px;
  padding-bottom: 13px;
  border-width: 1px;
  visibility: visible;
}

.form-actions {
  margin-top: 30px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}
.export-button-container {
  position: relative;
  display: inline-block;
}
.export-options-menu {
  display: none;
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--card-bg-color);
  min-width: 180px;
  box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
  z-index: 1;
  border-radius: 10px;
  padding: 8px 0;
  border: 1px solid var(--border-color);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s ease-in-out,
    bottom 0.2s ease-in-out;
}
.export-button-container.active .export-options-menu {
  display: block;
  opacity: 1;
  visibility: visible;
  bottom: 120%;
}
.export-options-menu a {
  color: var(--text-color);
  padding: 12px 16px;
  text-decoration: none;
  display: flex;
  align-items: center;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background-color 0.2s;
}
.export-options-menu a i {
  margin-right: 12px;
  color: var(--primary-color);
  width: 18px;
  text-align: center;
}
.export-options-menu a:hover {
  background-color: var(--primary-color-light-10);
  background-color: color-mix(in srgb, var(--primary-color) 10%, transparent);
}

#exportButton.is-loading i {
  pointer-events: none;
}
