/* =========================================================================
 * WAAS 부스앱 — 기준 해상도 1280×800 태블릿, 폭 360px까지 반응형
 * ========================================================================= */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --line: #dde2e9;
  --text: #1c2431;
  --text-dim: #63708a;
  --brand: #8b1a2b;          /* 고려대 크림슨 계열 */
  --brand-soft: #f4e9eb;
  --accent: #3b6fd4;
  --ok: #2e8b6f;
  --warn: #d98324;
  --bad: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 8px 24px rgba(20, 30, 50, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', -apple-system, 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  font-size: 17px;
  line-height: 1.62;
  -webkit-text-size-adjust: 100%;

  /* 한국어 줄바꿈: 어절 단위로만 끊는다(‘권합니 / 다’ 방지) */
  word-break: keep-all;
  overflow-wrap: break-word;
  line-break: strict;
}

/* 마지막 줄에 한 단어만 남는 것(고아 줄) 완화 */
p, .card-sub, .note, .nav-note, .disclaimer, .brief p, .q-text, .metric .s { text-wrap: pretty; }
h1, h2, .quad-name, .badge { text-wrap: balance; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 22px 72px; }
.wrap.narrow { max-width: 780px; }
.wrap.wide { max-width: 1240px; }

/* ------------------------------------------------------------- 헤더 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 14px 22px;
  background: var(--surface); border-bottom: 3px solid var(--brand);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.topbar .sub { color: var(--text-dim); font-size: 13px; margin-top: 1px; }

/* 기관 로고 + 서비스명 묶음 */
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand-logo {
  height: 44px; width: auto; flex: none;
  /* 원본 로고가 3단 구성이라 아주 작아지면 아래 한 줄이 뭉개진다. 최소 높이를 지킨다 */
  min-height: 30px;
}
.brand-div { width: 1px; align-self: stretch; margin: 2px 0; background: var(--line); flex: none; }
.brand h1 { white-space: nowrap; }

@media (max-width: 820px) {
  .brand { gap: 12px; }
  .brand-logo { height: 34px; }
  .topbar h1 { font-size: 17px; }
}
/* 폭이 아주 좁으면 로고만 남기고 서비스명 부제를 접는다 */
@media (max-width: 560px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand-logo { height: 30px; }
  .brand-div, .topbar .sub { display: none; }
  .topbar h1 { font-size: 15px; white-space: normal; }
}

/* ------------------------------------------------------------- 카드 */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px; margin-bottom: 18px;
}
.card > h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -.01em; }
.card > .card-sub { color: var(--text-dim); font-size: 14px; margin: 0 0 16px; }

/* ------------------------------------------------------------ 진행바 */
.progress-wrap { padding: 12px 22px 0; }
.progress-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.progress-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; display: flex; gap: 2px; }
.progress-track i { flex: 1; background: var(--surface-2); transition: background .25s; }
.progress-track i.done { background: var(--brand); }

/* ------------------------------------------------------------ 문항 */
.q { padding: 18px 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: 0; }
.q-text { font-size: 17px; font-weight: 600; margin-bottom: 14px; letter-spacing: -.01em; }
.q-text .num { color: var(--brand); margin-right: 8px; font-variant-numeric: tabular-nums; }

.likert { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.likert button {
  appearance: none; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 12px; padding: 12px 4px 10px;
  font-family: inherit; font-size: 13px; color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-height: 74px; transition: all .14s;
}
.likert button .n { font-size: 19px; font-weight: 700; color: var(--text); }
.likert button:hover { border-color: var(--brand); }
.likert button[aria-pressed="true"] {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.likert button[aria-pressed="true"] .n { color: #fff; }
.q.unanswered .q-text { color: var(--bad); }

/* ------------------------------------------------------------ 버튼 */
.btn {
  appearance: none; cursor: pointer; font-family: inherit; font-size: 16px; font-weight: 600;
  border-radius: 12px; padding: 13px 26px; border: 1.5px solid transparent;
  transition: all .14s;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.sm { font-size: 14px; padding: 8px 15px; border-radius: 9px; }

.nav-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 22px; }
.nav-note { color: var(--text-dim); font-size: 14px; }
.nav-note.alert { color: var(--bad); font-weight: 600; }

/* ------------------------------------------------------------- 동의 */
.consent {
  display: flex; align-items: flex-start; gap: 12px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 10px; transition: all .14s;
  font-size: 15.5px; line-height: 1.55;
}
.consent:hover { border-color: var(--brand); }
.consent:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.consent input[type="checkbox"] {
  width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--brand); cursor: pointer;
}
.consent .tag {
  display: inline-block; font-size: 11.5px; font-weight: 700; border-radius: 5px;
  padding: 2px 7px; margin-right: 7px; vertical-align: 2px;
}
.consent .tag.req { background: var(--brand); color: #fff; }
.consent .tag.opt { background: var(--surface-2); color: var(--text-dim); }

.contact-wrap { margin: -2px 0 12px; padding-left: 50px; }
.contact-wrap input {
  width: 100%; max-width: 380px; font-family: inherit; font-size: 16px;
  padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
.contact-wrap input:focus { outline: none; border-color: var(--brand); }
.hint { font-size: 13px; color: var(--text-dim); margin-top: 6px; }
.hint.err { color: var(--bad); font-weight: 600; }

.detail { margin: 6px 0 4px; }
.detail summary {
  cursor: pointer; font-size: 14px; color: var(--text-dim);
  padding: 8px 0; list-style-position: inside;
}
.detail summary:hover { color: var(--brand); }
.detail[open] summary { color: var(--text); font-weight: 600; }
dl.privacy { margin: 4px 0 0; font-size: 14px; line-height: 1.6; }
dl.privacy dt { font-weight: 700; color: var(--text); margin-top: 10px; }
dl.privacy dd { margin: 3px 0 0; color: var(--text-dim); }

@media (max-width: 620px) { .contact-wrap { padding-left: 0; } }

/* -------------------------------------------------------- 선택 필드 */
.demo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips button {
  appearance: none; cursor: pointer; font-family: inherit; font-size: 14px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text-dim);
  border-radius: 99px; padding: 7px 14px; transition: all .14s;
}
.chips button:hover { border-color: var(--brand); }
.chips button[aria-pressed="true"] { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }

/* ------------------------------------------------------------ 결과 */
/* 두 차트를 같은 폭으로 두어 카드 높이가 자연히 맞도록 한다 */
.result-top { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: stretch; }
.result-top > .card { display: flex; flex-direction: column; margin-bottom: 0; }
.result-top .chart { margin-top: auto; }
@media (max-width: 940px) { .result-top { grid-template-columns: 1fr; } .result-top > .card { margin-bottom: 18px; } }

.strip { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.strip .metric-row { flex: 1 1 420px; }
.strip .strip-note { flex: 1 1 300px; font-size: 13.5px; color: var(--text-dim); }

.badge-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.badge {
  border-radius: 99px; padding: 7px 16px; font-size: 14px; font-weight: 600;
  background: var(--surface-2); color: var(--text);
}
.badge.big { font-size: 16px; padding: 9px 20px; color: #fff; }

.metric-row { display: flex; gap: 12px; flex-wrap: wrap; }
.metric {
  flex: 1 1 130px; background: var(--surface-2); border-radius: 12px; padding: 13px 15px;
}
.metric .k { font-size: 12.5px; color: var(--text-dim); }
.metric .v { font-size: 25px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.metric .s { font-size: 12px; color: var(--text-dim); }

.interp p { margin: 0 0 12px; }
.interp strong { color: var(--brand); }

/* 넓은 화면에서 문장이 한없이 길어지지 않도록 읽기 폭을 고정하고,
   남는 폭은 요인 표에 내준다. 한국어는 한 줄 40~50자가 읽기 편하다. */
.interp-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .82fr); gap: 30px; align-items: start; }
/* 한글은 한 글자 폭이 대략 1em 이므로 em 으로 잡아야 글자 수가 예측된다 (≈36자/줄) */
.interp-text { max-width: 36em; }
.interp-text p:last-child { margin-bottom: 0; }
@media (max-width: 940px) { .interp-body { grid-template-columns: 1fr; gap: 18px; } .interp-text { max-width: none; } }

.disclaimer { font-size: 13px; color: var(--text-dim); border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px; }

/* ------------------------------------------------------------ 차트 */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis-line { stroke: var(--text-dim); stroke-width: 1; }
.chart .tick { fill: var(--text-dim); font-size: 11px; }
.chart .lbl { fill: var(--text); font-size: 13px; }
.chart .lbl.sm { font-size: 12px; }
.chart .lbl-rot { fill: var(--text); font-size: 12px; }
.chart .cap { fill: var(--text-dim); font-size: 11.5px; }
.chart .val { fill: var(--text); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .val.sm { font-size: 11.5px; }
.chart .dim { fill: var(--text-dim); }
.chart .ci { stroke: var(--text); stroke-width: 1.4; opacity: .55; }
.chart .norm-mark { stroke: var(--text); stroke-width: 1.6; stroke-dasharray: 3 3; opacity: .65; }
.chart .plot-bg { fill: var(--surface-2); opacity: .5; }
.chart .axis-mid { stroke: var(--text-dim); stroke-width: 1.2; opacity: .7; }
.chart .booth-mid { stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 6 4; opacity: .8; }
.chart .axis-title { fill: var(--text-dim); font-size: 12.5px; }
.chart .quad-name { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.chart .me-label { font-size: 14px; font-weight: 800; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.chart .axis-end { fill: var(--text-dim); font-size: 11px; }
.chart .radar-grid { fill: none; stroke: var(--line); stroke-width: 1; }
.chart .radar-spoke { stroke: var(--line); stroke-width: 1; }
.chart .donut-pct { fill: #fff; font-size: 13px; font-weight: 700; }
.chart .donut-total { fill: var(--text); font-size: 26px; font-weight: 700; }
.chart .cell-diag { fill: var(--surface-2); }
.chart .cell-txt { fill: var(--text); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .cell-sub { fill: var(--text-dim); font-size: 10.5px; }
.chart .whisker { stroke: var(--text-dim); stroke-width: 1.2; }
.chart .tl-bar { fill: var(--accent); opacity: .55; }
.chart .tl-line { fill: none; stroke: var(--brand); stroke-width: 2; }

/* ------------------------------------------------------------- 표 */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--text-dim); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
table.data td { font-variant-numeric: tabular-nums; }
table.data tr.small-n td { color: var(--text-dim); }
.table-scroll { overflow-x: auto; }

/* ------------------------------------------------------- 관리자 탭 */
.tabs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; }
.tabs button {
  appearance: none; cursor: pointer; font-family: inherit; font-size: 14px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text-dim);
  border-radius: 10px; padding: 9px 15px; transition: all .14s;
}
.tabs button:hover { border-color: var(--brand); }
.tabs button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.brief { background: var(--brand-soft); border-left: 4px solid var(--brand); border-radius: 0 12px 12px 0; padding: 18px 22px; }
.brief p { margin: 0 0 10px; }
.brief p:last-child { margin-bottom: 0; }
.brief strong { color: var(--brand); }
.brief .alert { color: var(--bad); font-weight: 600; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--text-dim); cursor: pointer; }

.empty { text-align: center; color: var(--text-dim); padding: 56px 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.note { font-size: 13px; color: var(--text-dim); background: var(--surface-2); border-radius: 10px; padding: 11px 14px; margin-top: 12px; }
.note.warn { background: #fdf3e6; color: #8a5410; }

/* --------------------------------------------------------- 상태 표시 */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 22px; border-radius: 99px;
  font-size: 14.5px; box-shadow: var(--shadow); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--bad); }

.queue-pill {
  font-size: 12.5px; color: var(--warn); background: #fdf3e6;
  border-radius: 99px; padding: 4px 12px; font-weight: 600;
}

.errbox {
  border: 1.5px solid var(--bad); background: #fdeceb; color: #7d1f16;
  border-radius: 12px; padding: 16px 18px; font-size: 14px; white-space: pre-wrap;
}

/* --------------------------------------------------------- 로그인 */
.pin-form { max-width: 340px; margin: 60px auto; text-align: center; }
.pin-form input {
  width: 100%; font-family: inherit; font-size: 24px; text-align: center; letter-spacing: .3em;
  padding: 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
  color: var(--text); margin: 16px 0;
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .wrap { padding: 14px 14px 60px; }
  .card { padding: 17px 16px; }
  .likert { gap: 5px; }
  .likert button { min-height: 66px; font-size: 11px; padding: 9px 2px 8px; }
  .likert button .n { font-size: 17px; }
}

@media print {
  .topbar, .nav-row, .tabs, .toolbar { display: none; }
  .card { break-inside: avoid; box-shadow: none; }
}
