:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --fg: #1a1d21;
  --muted: #6b7280;
  --line: #d8dce2;
  --accent: #2563eb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --card: #1d2126;
    --fg: #e8eaed;
    --muted: #9aa3ae;
    --line: #333a42;
    --accent: #60a5fa;
    --danger: #f87171;
    --danger-bg: #2a1516;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Pretendard", "Noto Sans KR", sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

h1 { font-size: 1.5rem; margin: 0 0 12px; letter-spacing: -0.01em; }
.lead { margin: 0 0 24px; }
.muted { color: var(--muted); font-size: 0.9rem; margin: 4px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}

.alert {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 16px;
  font-size: 0.95rem;
}

fieldset.q {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 20px 0 4px;
}
fieldset.q:first-of-type { border-top: none; padding-top: 0; }
fieldset.q-error { border-left: 3px solid var(--danger); padding-left: 12px; }

legend {
  font-weight: 600;
  padding: 0;
  margin-bottom: 8px;
}
.req { color: var(--danger); margin-left: 2px; }

label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
textarea { resize: vertical; }

input[type="text"]:focus, input[type="password"]:focus,
textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

label.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  padding: 8px 10px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.scale {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.scale-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-weight: 400;
  min-width: 44px;
  padding: 8px 4px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.field-error {
  color: var(--danger);
  font-size: 0.88rem;
  margin: 6px 0 0;
}

button {
  margin-top: 24px;
  width: 100%;
  padding: 13px 20px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }

a { color: var(--accent); }

/* 봇 감지용 필드. 화면과 스크린리더 양쪽에서 감춘다. */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------------------------------------------------------------- 성향 검사 결과
   CSP가 인라인 style을 막으므로 폭은 아래 w-* 클래스로만 준다(5% 단위). */

.result-head { text-align: center; margin-bottom: 16px; }

.type-code {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 4px 0 6px;
}

.meter {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
  margin-top: 12px;
}
.meter-fill { height: 100%; background: var(--accent); }

.axis { padding: 14px 0; border-top: 1px solid var(--line); }
.axis:first-child { border-top: none; padding-top: 0; }

.axis-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
}
.axis-end { color: var(--muted); }
.axis-end-right { text-align: right; }
.axis-verdict { font-weight: 700; font-size: 1.05rem; }

/* 축 막대: 가운데가 중립, 점이 왼쪽(pos)/오른쪽(neg)으로 이동 */
.track {
  position: relative;
  height: 10px;
  margin: 8px 0 6px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--line) 50%, var(--accent) 100%);
  opacity: 0.35;
}
.track-mid {
  position: absolute;
  left: 50%;
  top: -3px;
  width: 1px;
  height: 16px;
  background: var(--muted);
}
/* 폭(w-*)만큼 왼쪽에서 떨어진 지점에 오른쪽 테두리가 표시자로 선다. */
.track-dot {
  position: absolute;
  left: 0;
  top: -3px;
  height: 16px;
  border-right: 4px solid var(--fg);
  border-radius: 2px;
}

.axis-meta { display: flex; align-items: center; gap: 8px; margin: 0; }
.axis-settled .axis-verdict { color: var(--accent); }

.tag-ok, .tag-need {
  font-size: 0.75rem;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.tag-ok { color: var(--accent); }
.tag-need { color: var(--muted); }

.history { margin: 8px 0 0; padding-left: 20px; }
.history li { margin-bottom: 4px; }

.btn-link {
  display: block;
  text-align: center;
  padding: 13px 20px;
  margin-top: 8px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border-radius: 8px;
  text-decoration: none;
}
.btn-quiet {
  background: none;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 400;
  margin-top: 12px;
}

/* 5% 단위 폭. .track-dot에는 위치(왼쪽 여백)로, .meter-fill에는 폭으로 쓰인다. */
.w-0   { width: 0%; }   .w-5   { width: 5%; }   .w-10  { width: 10%; }
.w-15  { width: 15%; }  .w-20  { width: 20%; }  .w-25  { width: 25%; }
.w-30  { width: 30%; }  .w-35  { width: 35%; }  .w-40  { width: 40%; }
.w-45  { width: 45%; }  .w-50  { width: 50%; }  .w-55  { width: 55%; }
.w-60  { width: 60%; }  .w-65  { width: 65%; }  .w-70  { width: 70%; }
.w-75  { width: 75%; }  .w-80  { width: 80%; }  .w-85  { width: 85%; }
.w-90  { width: 90%; }  .w-95  { width: 95%; }  .w-100 { width: 100%; }

/* 문항이 12개라 리커트 5칸이 좁은 화면에서도 한 줄에 들어가야 한다. */
@media (max-width: 480px) {
  .scale-item { min-width: 0; flex: 1; font-size: 0.72rem; padding: 8px 2px; }
  .scale { flex-wrap: nowrap; gap: 4px; }
  .type-code { font-size: 2.1rem; }
}
