/* 2026 서울시 공공도서관 조사: colours follow the paper questionnaire (navy title bar, beige grid head,
   blue B rows, yellow C row, red 해당없음 banner). Mobile first; grids become tap rows under 640px. */
:root {
  --navy: #343a7c; --ink: #1f2233; --muted: #5d6173; --rule: #d6d9e4; --bg: #f5f6fa; --card: #fff;
  --head: #f6efd6; --b-row: #e6ebf8; --c-row: #fde68a; --section: #fff8d6; --section-rule: #cdb95b;
  --na: #c62828; --accent-soft: #e8eaf6; --error: #c62828; --error-soft: #fdecea; --focus: #f0b400;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 16px; line-height: 1.65; word-break: keep-all; overflow-wrap: anywhere; -webkit-text-size-adjust: 100%; }
.wrap { max-width: 900px; margin: 0 auto; padding: 20px 16px 48px; }
.top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.title { flex: 1 1 auto; margin: 0; background: var(--navy); color: #fff; font-size: 18px; font-weight: 700;
  padding: 12px 16px; border-radius: 4px; }
.preview-flag { background: #ffe08a; color: #5a4300; font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.progress { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums; }
.track { flex: 1; height: 8px; background: #dfe2ec; border-radius: 4px; overflow: hidden; }
.bar { height: 100%; background: var(--navy); }
form { display: grid; gap: 16px; }
.intro { background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 18px; }
.intro p { margin: 0 0 12px; }
.intro-title { margin: 0 0 12px; font-size: 18px; font-weight: 700; }
.intro .u { text-decoration: underline; }
.intro-date, .intro-contact { text-align: right; font-size: 14px; color: var(--muted); }
.orgs { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.orgs th, .orgs td { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); padding: 6px; text-align: center; }
.section { background: var(--section); border: 1px solid var(--section-rule); padding: 10px 14px; font-weight: 700; font-size: 15px; }
.na-banner { background: var(--na); color: #fff; font-weight: 700; font-size: 14px; text-align: center; padding: 8px 12px; }
.form-error { margin: 0; background: var(--error-soft); color: var(--error); font-weight: 700; padding: 10px 14px; border-radius: 6px; }
.q { background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 16px; min-width: 0; }
.q.has-error { border-color: var(--error); box-shadow: inset 0 0 0 1px var(--error); }
.qtext { margin: 0 0 6px; font-size: 17px; line-height: 1.5; font-weight: 700; }
.qnum { color: var(--navy); }
.qnote { margin: 0 0 10px; color: var(--muted); font-size: 14.5px; }
.qnote-strong { color: var(--ink); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.message .btn-link { display: inline-block; margin-top: 12px; background: var(--navy); color: #fff; font-weight: 700;
  text-decoration: none; padding: 11px 18px; border-radius: 8px; }
.qerror { margin: 0 0 10px; color: var(--error); font-weight: 700; font-size: 14.5px; }

/* choices */
.opts { display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); gap: 6px 10px; }
.opt { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-height: 44px; padding: 8px 10px;
  border: 1px solid var(--rule); border-radius: 6px; cursor: pointer; }
.opt:has(> input:checked) { border-color: var(--navy); background: var(--accent-soft); }
.opt > input[type=radio], .opt > input[type=checkbox] { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--navy); }
.olabel { flex: 1 1 0; min-width: 0; }
.odesc { display: block; color: var(--muted); font-size: 13px; }
.other { flex: 1 1 100%; font: inherit; padding: 6px 8px; border: 1px solid #b9bdcc; border-radius: 4px; }
.other[readonly], .freq-n[readonly] { background: #eef0f5; color: var(--muted); }
.counter { margin: 8px 0 0; font-size: 13.5px; color: var(--muted); }
.opts-scale { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.opts-scale .opt { flex-direction: column; justify-content: flex-start; text-align: center; padding: 8px 2px; gap: 4px; }
.opts-scale .olabel { flex: none; font-size: 12.5px; line-height: 1.3; }
.onum { display: block; font-size: 16px; }

/* matrix (desktop: table-like grid) */
.matrix { --pt: 3.1rem; border-top: 2px solid var(--ink); }
.mhead, .mrow { display: grid; grid-template-columns: minmax(0, 1fr) repeat(var(--ncols), var(--pt)); align-items: stretch; }
.matrix.semantic .mhead, .matrix.semantic .mrow { grid-template-columns: minmax(5.5rem, 1fr) repeat(7, var(--pt)) minmax(5.5rem, 1fr); }
.mhead { background: var(--head); font-weight: 700; font-size: 12.5px; line-height: 1.25; text-align: center; border-bottom: 2px solid var(--ink); }
.mhead > div { display: flex; align-items: center; justify-content: center; padding: 8px 2px; }
.mhead .mhead-item { font-size: 15px; }
.mrow { border-bottom: 1px solid var(--rule); }
.mrow.group-B { background: var(--b-row); }
.mrow.group-C { background: var(--c-row); }
.mrow.gstart { border-top: 10px solid var(--card); }
.mlabel { padding: 8px 10px; font-size: 15px; align-self: center; }
.mlabel b { margin-right: 2px; }
.matrix.semantic .mlabel { text-align: center; }
.matrix.semantic .mhead-pt { white-space: nowrap; }  /* '반반이다' on one line; neighbours are empty */
.sd-pair { display: none; }
.mscale { display: contents; }
.pt { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px;
  border-left: 1px solid var(--rule); cursor: pointer; }
.pt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pt span { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid #b9bdcc; background: #fff; font-size: 14px; font-variant-numeric: tabular-nums; }
.pt input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; font-weight: 700; }
.pt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.pt small { display: none; }
.pt.blank { cursor: default; background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(0, 0, 0, .07) 6px 7px); }
.mright { padding: 8px 10px; text-align: center; font-size: 15px; align-self: center; }
.mends { display: none; }
.mrow.missing .mlabel { color: var(--error); font-weight: 700; }

/* numbers, selects, phone */
input[type=text][inputmode=numeric] { font: inherit; font-size: 17px; width: 5.5em; padding: 8px 10px;
  border: 1px solid #b9bdcc; border-radius: 6px; text-align: right; font-variant-numeric: tabular-nums; }
.num-field, .ym, .phone, .freq-field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ym label { display: flex; align-items: center; gap: 6px; }
.ng { display: grid; gap: 8px; }
.ng-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 6px 0; border-bottom: 1px solid var(--rule); }  /* label wraps on the left; boxes stay in one column */
.ng-input { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.phone input { text-align: center; width: 5em; }
.phone input[maxlength="3"] { width: 4.2em; }
select { font: inherit; font-size: 16px; width: 100%; padding: 9px 10px; border: 1px solid #b9bdcc; border-radius: 6px; background: #fff; }
.lib { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lib label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.freq { display: grid; gap: 8px; }
.freq-opt { justify-content: space-between; }
.rank, .text-field { display: grid; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 4.5em minmax(0, 1fr); align-items: center; gap: 8px; }
.rank-n { font-weight: 700; color: var(--navy); }
.rank-other { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.consent { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; padding: 14px; border: 2px solid var(--navy);
  border-radius: 8px; cursor: pointer; }
.consent input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--navy); }
.notice { background: var(--section); border: 1px solid var(--section-rule); padding: 12px 14px; font-weight: 700; }
.nav { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.btn-next { margin-left: auto; min-width: 9em; font: inherit; font-size: 17px; font-weight: 700; color: #fff; background: var(--navy);
  border: 0; border-radius: 8px; padding: 13px 28px; cursor: pointer; }
.btn-next:disabled { opacity: .6; }
.btn-prev { color: var(--navy); font-weight: 600; text-decoration: none; padding: 13px 8px; }
.message { background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 24px 20px; }
.message strong { display: block; font-size: 20px; line-height: 1.45; margin-bottom: 8px; }
.message p { margin: 8px 0 0; color: var(--muted); }
.foot { margin-top: 28px; font-size: 13px; color: var(--muted); text-align: center; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

@media (max-width: 640px) {
  .opts { grid-template-columns: repeat(var(--cols-sm, 1), minmax(0, 1fr)); }
  .opts-scale { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .opts-scale .olabel { font-size: 11px; }
  .lib { grid-template-columns: 1fr; }
  .mhead { display: none; }
  .mrow, .matrix.semantic .mrow { display: block; padding: 10px 0 12px; }
  .mrow.gstart { border-top-width: 6px; }
  .mlabel { padding: 0 4px 8px; }
  .sd-pair { display: inline; }
  .mscale { display: grid; grid-template-columns: repeat(var(--ncols), minmax(0, 1fr)); gap: 4px; padding: 0 2px; }
  .pt { border-left: 0; min-height: 48px; }
  .pt span { width: 100%; max-width: 44px; height: 40px; border-radius: 8px; }
  /* 해당없음 label sits above the 9 box so every box stays on one line */
  .matrix.has-na .mscale, .matrix.semantic .mscale { padding-top: 16px; }
  .matrix.semantic .mlabel { text-align: left; }
  .pt.na small, .pt small.mid { display: block; position: absolute; top: -15px; left: 0; right: 0; text-align: center;
    font-size: 10.5px; line-height: 1.2; color: var(--muted); white-space: nowrap; }
  .mright { display: none; }
  /* end labels line up with the 1 and 7 boxes, never under the 9 (해당없음) box */
  .mends { display: grid; grid-template-columns: repeat(var(--ncols), minmax(0, 1fr)); gap: 4px; font-size: 12px;
    color: var(--muted); padding: 4px 2px 0; }
  .mends span:first-child { grid-row: 1; grid-column: 1 / span 3; text-align: left; white-space: nowrap; }
  .mends span:last-child { grid-row: 1; grid-column: 4 / span 4; text-align: right; white-space: nowrap; }
  .btn-next { flex: 1; }
}
