:root {
  --navy: #12294d;
  --blue: #1f5fb8;
  --blue-light: #e8f0fc;
  --gray-900: #1a1d23;
  --gray-700: #4a4f58;
  --gray-500: #7a8090;
  --gray-300: #d8dce2;
  --gray-100: #f4f6f9;
  --white: #ffffff;
  --red: #c0392b;
  --radius: 10px;
  --max-width: 720px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--gray-100);
  color: var(--gray-900);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 16px 120px;
}

.header {
  background: var(--navy);
  color: var(--white);
  padding: 20px 16px;
}
.header .wrap { padding: 0; }
.header h1 {
  font-size: 1.15rem;
  margin: 0 0 4px;
}
.header p {
  font-size: 0.85rem;
  color: #c9d6ea;
  margin: 0;
}

.progress-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--white);
  border-bottom: 1px solid var(--gray-300);
  padding: 10px 16px;
}
.progress-bar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}
.progress-track {
  height: 6px;
  background: var(--gray-300);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--blue);
  transition: width 0.25s ease;
}
.progress-label {
  font-size: 0.78rem;
  color: var(--gray-700);
  display: flex;
  justify-content: space-between;
}

.part-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
  margin: 24px 0 4px;
}
.part-note {
  font-size: 0.85rem;
  color: var(--gray-700);
  background: var(--blue-light);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 18px;
}

.save-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--navy);
  background: var(--blue-light);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 18px;
  line-height: 1.6;
}
.save-notice .save-notice-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1.4;
}

.q-card {
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
}
.q-card.has-error {
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red);
}
.q-title {
  font-weight: 600;
  font-size: 0.98rem;
  margin: 0 0 4px;
}
.q-title .q-no {
  color: var(--blue);
  margin-right: 6px;
}
.q-note {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin: 0 0 12px;
}
.q-error {
  font-size: 0.8rem;
  color: var(--red);
  margin-top: 8px;
  display: none;
}
.q-card.has-error .q-error { display: block; }

.opt-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.opt-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.92rem;
}
.opt-row:hover { border-color: var(--blue); }
.opt-row input { margin-top: 3px; flex-shrink: 0; }
.opt-row.checked { border-color: var(--blue); background: var(--blue-light); }

.other-text {
  margin-top: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

.scale-row { display: flex; align-items: center; gap: 4px; margin-top: 10px; }
.scale-labels { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--gray-500); margin-top: 4px; }
.scale-opt {
  flex: 1;
  text-align: center;
  padding: 10px 2px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-700);
}
.scale-opt.checked { border-color: var(--blue); background: var(--blue); color: var(--white); }
.scale-na {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}
.scale-na.checked { border-color: var(--blue); background: var(--blue-light); }

.matrix-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.85rem; }
.matrix-table th { font-weight: 600; color: var(--gray-700); padding: 6px 4px; text-align: center; font-size: 0.78rem; }
.matrix-table td { padding: 6px 4px; text-align: center; border-top: 1px solid var(--gray-300); }
.matrix-table td.item-label { text-align: left; font-size: 0.85rem; padding-right: 8px; }
.matrix-table input[type="radio"] { width: 18px; height: 18px; }

.matrix-cards { display: none; }

@media (max-width: 560px) {
  .matrix-table { display: none; }
  .matrix-cards { display: block; margin-top: 10px; }
  .matrix-card {
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
  }
  .matrix-card .item-label { font-weight: 600; font-size: 0.88rem; margin-bottom: 8px; }
  .matrix-card .dim-block { margin-top: 8px; }
  .matrix-card .dim-block-label { font-size: 0.78rem; color: var(--gray-500); margin-bottom: 4px; }
}

.rank-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.rank-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}
.rank-opt.checked { border-color: var(--blue); background: var(--blue-light); }
.rank-badge {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--gray-300);
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.rank-opt.checked .rank-badge { background: var(--blue); }
.rank-reset { margin-top: 8px; background: none; border: none; color: var(--blue); font-size: 0.82rem; cursor: pointer; padding: 4px 0; }

textarea.text-answer {
  width: 100%;
  min-height: 90px;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  margin-top: 8px;
}
.char-count { text-align: right; font-size: 0.72rem; color: var(--gray-500); margin-top: 2px; }

.essay-field { margin-top: 12px; }
.essay-field-label { font-size: 0.85rem; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }

.nav-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-top: 1px solid var(--gray-300);
  padding: 12px 16px;
  z-index: 20;
}
.nav-bar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  gap: 10px;
}
.btn {
  flex: 1;
  padding: 13px 16px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:disabled { background: var(--gray-300); cursor: not-allowed; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-300); flex: 0 0 90px; }

.center-screen {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}
.center-screen h2 { color: var(--navy); margin-bottom: 8px; }
.center-screen p { color: var(--gray-700); }

.banner-error {
  background: #fdecea;
  border: 1px solid #f5c2bd;
  color: var(--red);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

[role="button"]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--gray-300);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
