:root {
  color-scheme: light;
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #f0f6f4;
  --text: #1c2526;
  --muted: #5b6769;
  --line: #d6dedb;
  --accent: #0f766e;
  --accent-2: #a6422b;
  --shadow: 0 18px 50px rgba(28, 37, 38, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  line-height: 1.6;
}

button,
input {
  font: inherit;
}

.app-header {
  background: #163536;
  color: #fff;
  padding: 22px 20px 28px;
}

.header-inner,
.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #bfe5df;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  line-height: 1.2;
}

.app-shell {
  padding: 22px 20px 44px;
}

.result-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.result-panel-bottom {
  margin-bottom: 0;
  box-shadow: none;
}

.result-panel[hidden] {
  display: none;
}

.result-panel h2 {
  margin: 0;
  font-size: 1.15rem;
}

.score-card {
  display: grid;
  gap: 12px;
}

.score-card > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.score-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.score-card strong {
  display: block;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.1;
}

.score-graph {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.score-track {
  position: relative;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: visible;
  background: #fff;
}

.score-range {
  position: absolute;
  top: 0;
  bottom: 0;
  opacity: 0.75;
}

.score-range-male {
  left: 0;
  width: 60%;
  background: #2f80ed;
}

.score-range-female {
  left: 50%;
  width: 50%;
  background: #e04f5f;
}

.score-overlap {
  position: absolute;
  left: 50%;
  top: 0;
  width: 10%;
  height: 100%;
  background: #f4c430;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  z-index: 2;
}

.score-marker {
  position: absolute;
  top: -7px;
  bottom: -7px;
  left: var(--score-position, 0%);
  width: 3px;
  border-radius: 999px;
  background: #172124;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9);
  transform: translateX(-50%);
  z-index: 3;
}

.score-marker::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid #172124;
  transform: translateX(-50%);
}

.score-scale {
  position: relative;
  height: 18px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.score-scale span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
}

.score-scale span:nth-child(1) {
  left: 0;
  transform: none;
}

.score-scale span:nth-child(2) {
  left: 50%;
}

.score-scale span:nth-child(3) {
  left: 60%;
}

.score-scale span:nth-child(4) {
  left: 100%;
  transform: translateX(-100%);
}

.score-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.score-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.score-legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-male {
  background: #2f80ed;
}

.legend-female {
  background: #e04f5f;
}

.legend-overlap {
  background: #f4c430;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 13px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.button:hover {
  border-color: var(--accent);
}

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

.button.danger {
  border-color: rgba(166, 66, 43, 0.35);
  color: var(--accent-2);
}

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

.question-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}

.gender-card {
  margin-bottom: 14px;
}

.question-card.is-error {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(166, 66, 43, 0.13);
}

.question-title {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.45;
}

.select-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.select-control {
  width: min(360px, 100%);
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  margin-bottom: 20px;
}

.select-control:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.options {
  display: grid;
  gap: 8px;
}

.option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
}

.option:hover {
  border-color: rgba(15, 118, 110, 0.55);
}

.option input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  accent-color: var(--accent);
}

.option-text {
  display: block;
  min-width: 0;
}

.option-key {
  display: inline-block;
  min-width: 1.6em;
  color: var(--accent);
  font-weight: 900;
}

.question-error {
  margin: 2px 0 0;
  color: var(--accent-2);
  font-size: 0.88rem;
  font-weight: 800;
}

.submit-panel {
  display: grid;
  gap: 10px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}

.submit-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.form-message {
  min-height: 1.5em;
  margin: 0;
  color: var(--accent-2);
  font-weight: 800;
}

@media (max-width: 880px) {
  .header-inner {
    align-items: stretch;
    flex-direction: column;
  }

  .actions {
    justify-content: stretch;
  }

  .button {
    flex: 1 1 128px;
  }

  .submit-actions {
    grid-template-columns: 1fr;
  }

  .card-actions {
    justify-content: stretch;
  }

}

@media (max-width: 520px) {
  .app-header {
    padding: 18px 14px 22px;
  }

  .app-shell {
    padding: 14px 12px 32px;
  }

  .question-card {
    padding: 13px;
  }

  .option {
    padding: 9px;
  }
}
