/* =====================================================================
   글꼴: Pretendard (SIL OFL 1.1, 무료) — 한글 가독성이 높은 고딕체, 앱에 내장(인터넷 불필요)
   색: 모든 본문 글자는 흰 배경 대비 7:1 이상 (WCAG AAA)
   ===================================================================== */
@font-face {
  font-family: "Pretendard";
  src: url("../fonts/PretendardVariable.woff2") format("woff2-variations"), url("../fonts/PretendardVariable.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
}
:root {
  --bg: #f2f4f7; --card: #ffffff; --ink: #111827; --ink2: #374151; --muted: #4b5563; --line: #c7cdd6;
  --pri: #0b3a66; --pri-ink: #fff; --pri-soft: #e3edf8;
  --ok: #14532d; --ok-soft: #dcfce7; --warn: #7c4a03; --warn-soft: #fff3d6; --bad: #991b1b; --bad-soft: #fde2e2;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Pretendard", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 18px; line-height: 1.5; word-break: keep-all; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
h1 { font-size: 1.6rem; margin: 0 0 16px; font-weight: 800; }
h2 { font-size: 1.2rem; margin: 26px 0 10px; font-weight: 700; }
b { font-weight: 700; }
button { font: inherit; cursor: pointer; color: inherit; }
input, textarea { font: inherit; width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
input:focus, textarea:focus { outline: 3px solid #93b4d8; border-color: var(--pri); }
input.short { max-width: 240px; }
textarea { font-family: ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); } .small { font-size: .88rem; }

/* ---------- 상단 바 (의료진) ---------- */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--pri); color: #fff; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; }
.brand { font-size: 1rem; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav { background: transparent; color: #fff; border: 0; padding: 10px 14px; border-radius: 8px; font-weight: 600; }
.nav.on { background: #fff; color: var(--pri); }
.nav.lockbtn { border: 2px solid rgba(255,255,255,.7); }
.banner { background: var(--warn-soft); color: var(--warn); padding: 8px 16px; font-size: .92rem; font-weight: 600; }
.banner.warn { background: var(--bad-soft); color: var(--bad); }
main { max-width: 1100px; margin: 0 auto; padding: 22px 16px 60px; }

/* ---------- 버튼 ---------- */
.btn { background: #fff; border: 2px solid var(--line); color: var(--ink); padding: 12px 18px; border-radius: 10px; min-height: 52px; font-weight: 600; }
.btn.primary { background: var(--pri); color: var(--pri-ink); border-color: var(--pri); }
.btn.danger { color: var(--bad); border-color: #e7a9a9; }
.btn.small { padding: 6px 12px; min-height: 40px; font-size: .92rem; }
.btn.big { font-size: 1.2rem; min-height: 64px; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.link { background: none; border: 0; color: var(--pri); text-decoration: underline; padding: 4px 6px; font-weight: 600; }
.link.danger { color: var(--bad); }
.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.row.wrap { flex-wrap: wrap; justify-content: flex-start; }
.row input { flex: 1; }

/* ---------- 카드 ---------- */
.center-card { max-width: 500px; margin: 7vh auto; background: var(--card); padding: 28px; border-radius: var(--r); border: 1px solid var(--line); }
.center-card input, .center-card textarea { margin-bottom: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 16px; overflow-x: auto; }
.card h2 { margin-top: 0; }
.card.warnc { background: var(--warn-soft); border-color: #e9c46a; }
.card-h { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.note { background: var(--pri-soft); padding: 10px 14px; border-radius: 10px; margin: 8px 0; }
.note.warn { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.warn-t { color: var(--warn); font-weight: 600; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; background: var(--bg); padding: 14px; border-radius: 10px; word-break: break-all; line-height: 1.7; }
.qr { display: flex; justify-content: center; margin: 16px 0 6px; }
.check { display: flex; gap: 10px; align-items: center; margin: 14px 0 4px; }
.check input { width: 26px; height: 26px; }

/* ---------- 등록 폼 ---------- */
.form { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.form > label { display: block; font-weight: 700; margin: 20px 0 8px; }
.form > label:first-child { margin-top: 0; }
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.tg { background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: 12px 16px; min-height: 52px; font-weight: 600; }
.tg.on { background: var(--pri); color: #fff; border-color: var(--pri); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-block; background: var(--pri-soft); color: var(--pri); border-radius: 999px; padding: 3px 10px; font-size: .85rem; font-weight: 600; margin: 2px 2px 2px 0; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- 표 ---------- */
.tbl { width: 100%; border-collapse: collapse; background: var(--card); }
.tbl th, .tbl td { text-align: left; padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { font-size: .85rem; color: var(--muted); font-weight: 700; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover { background: var(--pri-soft); }
.badge { display: inline-block; border-radius: 6px; padding: 3px 8px; font-size: .83rem; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.open { background: var(--pri-soft); color: var(--pri); }
.badge.wait { background: #e5e7eb; color: var(--ink2); }
.badge.late { background: var(--bad-soft); color: var(--bad); }
.pt-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.mrn { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.mrn-s { font-weight: 700; font-variant-numeric: tabular-nums; }
.count { background: var(--pri); color: #fff; border-radius: 999px; padding: 1px 10px; font-size: .88rem; margin-left: 6px; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; min-width: 100px; }
.stat b { font-size: 1.45rem; }

/* ---------- 설문 세션 (의료진) ---------- */
.qlist { margin: 16px 0; }
.qrow { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 10px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.qrow.col { flex-direction: column; align-items: stretch; }
.citem { margin: 8px 0; } .ctext { font-weight: 700; margin-bottom: 6px; }
.citem .tg { font-size: .95rem; padding: 10px 12px; text-align: left; }

/* ---------- PIN ---------- */
.pin { text-align: center; }
.dots { display: flex; justify-content: center; gap: 18px; margin: 22px 0; }
.dot { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--pri); }
.dot.on { background: var(--pri); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 0 auto 10px; }
.key { height: 72px; font-size: 1.8rem; font-weight: 700; border-radius: 14px; border: 2px solid var(--line); background: #fff; }
.key:active { background: var(--pri-soft); }

/* =====================================================================
   환자 작성 화면 — 70~80대 기준
   · 흰 바탕 + 거의 검정 글자 (회색 글자 사용 안 함)
   · 문항 36px, 선택지 26px 굵게, 줄간격 넉넉히
   · 선택 상태는 색 + 체크 표시 + 굵은 테두리 (색약도 구분 가능)
   ===================================================================== */
body.runmode { background: #fff; }
.run { --fs-q: 2.25rem; --fs-o: 1.6rem; max-width: 900px; margin: 0 auto; padding: 0 24px 150px; min-height: 100vh; font-size: 22px; line-height: 1.55; color: var(--ink); }
.run.xl { --fs-q: 2.75rem; --fs-o: 2rem; }
.run-top { position: sticky; top: 0; background: #fff; padding: 16px 0 10px; z-index: 3; border-bottom: 2px solid #e5e7eb; }
.bar { height: 18px; background: #e5e7eb; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #15803d; transition: width .25s; }
.run-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; font-size: 1.3rem; }
.run-meta .pos { font-size: 1.6rem; color: var(--pri); }
.run-tools { display: flex; align-items: center; gap: 14px; }
.tool { border: 2px solid var(--ink2); background: #fff; border-radius: 10px; padding: 8px 14px; font-size: 1.05rem; font-weight: 700; min-height: 48px; }
.link.staff { font-size: .9rem; color: var(--muted); font-weight: 500; }
.intro { font-size: 1.45rem; font-weight: 600; line-height: 1.6; background: #fff8e1; border: 2px solid #f0c75e; padding: 16px 20px; border-radius: 14px; margin: 22px 0 0; }
.remind { font-size: 1.1rem; color: var(--ink2); margin: 16px 0 0; padding-left: 14px; border-left: 5px solid #f0c75e; }
.qhead { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; margin: 26px 0 24px; }
.qtext { font-size: var(--fs-q); font-weight: 800; line-height: 1.4; margin: 0; letter-spacing: -0.01em; }
.speak { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 104px; min-height: 92px;
  border-radius: 16px; border: 3px solid var(--pri); background: var(--pri-soft); color: var(--pri); font-size: 1.05rem; font-weight: 800; }
.speak:active { background: var(--pri); color: #fff; }

.opts { display: flex; flex-direction: column; gap: 16px; }
.opt { display: flex; align-items: center; gap: 20px; text-align: left; background: #fff; border: 3px solid #6b7280; border-radius: 16px;
  padding: 22px 24px; font-size: var(--fs-o); font-weight: 600; line-height: 1.45; min-height: 92px; color: var(--ink); }
.opt .radio { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 4px solid #6b7280; background: #fff; position: relative; }
.opt.on { background: var(--pri); border-color: var(--pri); color: #fff; box-shadow: 0 0 0 4px #93b4d8; }
.opt.on .radio { border-color: #fff; background: #fff; }
.opt.on .radio::after { content: ""; position: absolute; left: 12px; top: 3px; width: 11px; height: 22px; border: solid var(--pri); border-width: 0 6px 6px 0; transform: rotate(45deg); }
.opt.skip { font-size: 1.3rem; min-height: 76px; border-style: dashed; }
.opt:active:not(.on) { background: var(--pri-soft); }

.scale { display: grid; grid-template-columns: repeat(11, 1fr); gap: 8px; }
.sc { min-height: 96px; font-size: 2.1rem; font-weight: 800; border-radius: 14px; border: 3px solid #6b7280; background: #fff; color: var(--ink); font-variant-numeric: tabular-nums; }
.sc0{background:#dcfce7}.sc1{background:#e3f9d9}.sc2{background:#ecf7d0}.sc3{background:#f5f3c8}.sc4{background:#fbedc2}.sc5{background:#fde5bf}
.sc6{background:#fddbbb}.sc7{background:#fcd0b7}.sc8{background:#fbc4b4}.sc9{background:#f9b8b2}.sc10{background:#f7acb0}
.sc.on { background: var(--pri); color: #fff; border-color: var(--pri); box-shadow: 0 0 0 5px #93b4d8; transform: scale(1.06); }
.scale-l { display: flex; justify-content: space-between; gap: 24px; margin-top: 14px; font-size: 1.3rem; font-weight: 700; color: var(--ink); }
.scale-l span:last-child { text-align: right; }
.s100 { text-align: center; }
.s100-v { font-size: 5rem; font-weight: 800; color: var(--pri); line-height: 1.1; font-variant-numeric: tabular-nums; }
.s100-v small { font-size: 1.8rem; color: var(--ink2); }
.s100-btns { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 14px 0 20px; }
.s100-btns .sc { background: #fff; min-height: 84px; font-size: 1.9rem; }
.s100 input[type=range] { width: 100%; height: 64px; padding: 0; border: 0; background: transparent; accent-color: var(--pri); }

.run-foot { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr 2fr; gap: 16px; max-width: 940px; margin: 0 auto;
  padding: 14px 20px calc(16px + env(safe-area-inset-bottom)); background: #fff; border-top: 2px solid #e5e7eb; z-index: 4; }
.run-foot .btn { min-height: 84px; font-size: 1.75rem; font-weight: 800; border-radius: 18px; border-width: 3px; }
.run-foot .prev { border-color: #6b7280; }
.run-foot .next:not(:disabled) { background: #15803d; border-color: #15803d; color: #fff; }
.run-foot .next:disabled { opacity: 1; background: #e5e7eb; border-color: #d1d5db; color: var(--ink2); font-size: 1.35rem; }
.run-foot .prev:disabled { opacity: .3; }

.run.done { text-align: center; padding-top: 16vh; }
.run.done h1 { font-size: 2.6rem; font-weight: 800; }
.run.done .intro { background: none; border: 0; font-size: 1.7rem; }
.run.done .btn { font-size: 1rem; min-height: 48px; margin-top: 40px; color: var(--muted); }
.big-check { width: 140px; height: 140px; margin: 0 auto 20px; border-radius: 50%; background: #15803d; color: #fff; font-size: 5rem; line-height: 140px; font-weight: 800; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: 14px 22px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .2s; max-width: 90vw; z-index: 50; font-weight: 600; }
#toast.on { opacity: .96; transform: translateX(-50%); }
body.runmode #toast { bottom: auto; top: 20px; }

@media (max-width: 760px) {
  .run { --fs-q: 1.75rem; --fs-o: 1.3rem; padding: 0 14px 140px; }
  .run.xl { --fs-q: 2.1rem; --fs-o: 1.55rem; }
  .scale { grid-template-columns: repeat(6, 1fr); }
  .speak { width: 84px; min-height: 80px; }
  .tbl th, .tbl td { padding: 8px 4px; font-size: .92rem; }
}
@media print {
  .noprint, .topbar, .banner, #toast { display: none !important; }
  .center-card { border: 0; margin: 0 auto; }
}

/* ===== 공식 eCOA 지침 반영 (ODI eBooklet 등) ===== */
/* 한 화면 안의 선택지 버튼은 글 길이와 무관하게 모두 같은 크기 */
.opts { display: grid; grid-template-columns: 1fr; grid-auto-rows: 1fr; }
/* 제목·안내·최종확인 화면 */
.prescreen { min-height: 50vh; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 28px; padding: 30px 6px; }
.ptitle { font-size: 2.6rem; font-weight: 800; line-height: 1.35; white-space: pre-line; margin: 0; }
.ptext { font-size: 1.7rem; font-weight: 600; line-height: 1.7; text-align: left; margin: 0; }
.pfoot { font-size: 1rem; color: var(--ink2); margin-top: 40px; }
.run.xl .ptext { font-size: 2.1rem; }
/* 무응답 확인 팝업 */
.modal-bg { position: fixed; inset: 0; background: rgba(17,24,39,.55); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 20px; }
.modal { background: #fff; border-radius: 20px; padding: 32px 28px; max-width: 640px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal p { font-size: 1.7rem; font-weight: 700; line-height: 1.6; margin: 0 0 28px; text-align: center; }
.modal-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-btns .btn { min-height: 80px; font-size: 1.4rem; font-weight: 800; border-width: 3px; border-radius: 16px; }
#scrollHint { position: fixed; left: 50%; transform: translateX(-50%); background: #fff8e1; color: var(--ink); border: 3px solid #f0c75e; border-radius: 999px;
  padding: 10px 22px; font-size: 1.15rem; font-weight: 800; z-index: 5; display: none; box-shadow: 0 4px 12px rgba(0,0,0,.15); cursor: pointer; }
#scrollHint.on { display: block; }
/* 작성 방식 */
.startbox { display: grid; gap: 10px; margin: 14px 0; }
.ivbox { background: #fff8e1; border: 2px solid #f0c75e; border-radius: 12px; padding: 14px; }
.ivbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; background: #fff3d6; border: 2px solid #e9a23b;
  color: var(--warn); font-weight: 800; border-radius: 10px; padding: 8px 14px; font-size: 1.05rem; }
.ivbar .link { font-size: .9rem; color: var(--warn); }
.ivswitch { text-align: right; margin-top: 4px; }
/* 제작자 표시 */
#credit { text-align: right; padding: 6px 16px 18px; font-size: .78rem; color: var(--muted); max-width: 1100px; margin: 0 auto; }
body.runmode #credit { display: none; }
/* 수술명 검색 결과 */
.presults { display: grid; gap: 6px; margin-top: 8px; max-height: 360px; overflow-y: auto; }
.pres { text-align: left; background: #fff; border: 2px solid var(--line); border-radius: 10px; padding: 12px 14px; min-height: 48px; font-size: .95rem; }
.pres:hover, .pres:active { border-color: var(--pri); background: var(--pri-soft); }
.toggles.area .tg.big { min-width: 180px; min-height: 60px; font-size: 1.1rem; }
.subreg { margin-top: 8px; padding-left: 4px; }
.subreg .tg { min-height: 44px; padding: 8px 18px; }
details.fu { margin-top: 6px; } details.fu summary { cursor: pointer; color: var(--pri); font-weight: 600; padding: 6px 0; }
