/* 표쌤코딩 QR 활동지 — 자체 스타일 (외부 CDN 의존 없음).
   학교 와이파이에서 CDN 이 막히거나 느린 경우가 많아 전부 자체 호스팅한다. */

:root {
  --bg: #f1f6fb;
  --card: #ffffff;
  --ink: #1e293b;
  --ink-soft: #64748b;
  --ink-faint: #94a3b8;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff6ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --bad: #e11d48;
  --bad-soft: #fff1f2;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 96px; }
.wrap-narrow { max-width: 460px; }

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

/* ---------------------------------------------------------------- 헤더 */

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { font-weight: 800; font-size: 17px; color: var(--ink); text-decoration: none; }
.brand span { color: var(--brand); }
.topnav { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.topnav a {
  padding: 7px 12px; border-radius: 10px; font-size: 14px; font-weight: 700;
  color: var(--ink-soft); text-decoration: none;
}
.topnav a:hover { background: var(--bg); color: var(--ink); }
.topnav a.on { background: var(--brand-soft); color: var(--brand); }
.topnav .who { font-size: 13px; color: var(--ink-faint); padding: 7px 4px; }

/* ---------------------------------------------------------------- 공통 */

h1 { font-size: 26px; font-weight: 800; margin: 0 0 6px; letter-spacing: -.02em; }
h2 { font-size: 19px; font-weight: 800; margin: 0 0 14px; }
h3 { font-size: 16px; font-weight: 800; margin: 0; }
.sub { color: var(--ink-soft); margin: 0 0 24px; }
.page-head { margin-bottom: 24px; display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 240px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card.tight { padding: 16px; }

.muted { color: var(--ink-faint); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }

/* ---------------------------------------------------------------- 버튼 */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 12px; border: 1px solid transparent;
  font-size: 14px; font-weight: 800; cursor: pointer; text-decoration: none;
  background: var(--brand); color: #fff; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--ink-soft); border-color: var(--line); }
.btn.ghost:hover { background: var(--bg); color: var(--ink); }
.btn.soft { background: var(--brand-soft); color: var(--brand); }
.btn.soft:hover { background: #dbeafe; }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.danger:hover { background: #ffe4e6; }
.btn.big { width: 100%; padding: 16px; font-size: 16px; border-radius: 14px; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }

/* ---------------------------------------------------------------- 폼 */

label.field { display: block; }
.field > .lab {
  display: block; font-size: 13px; font-weight: 800; color: var(--ink-soft); margin-bottom: 6px;
}
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  font-size: 15px; font-family: inherit; outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { resize: vertical; min-height: 90px; }
.hint { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 700; color: var(--ink-soft); }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }

/* 봇 유인용 — 사람 눈에는 안 보인다 */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---------------------------------------------------------------- 알림 */

.alert { padding: 13px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; margin-bottom: 18px; }
.alert.err { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--brand-soft); color: var(--brand-dark); }

/* ---------------------------------------------------------------- 배지 */

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800;
  background: var(--bg); color: var(--ink-soft);
}
.tag.brand { background: var(--brand-soft); color: var(--brand); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------------------------------------------------------------- 목록 */

.item {
  display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap;
  padding: 18px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; margin-bottom: 12px; box-shadow: var(--shadow);
}
.item .grow { flex: 1; min-width: 220px; }
.item .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; padding: 64px 20px; color: var(--ink-faint); font-weight: 700; }
.empty .big-ico { font-size: 40px; display: block; margin-bottom: 12px; opacity: .5; }

.linkbox {
  display: inline-block; padding: 8px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  word-break: break-all; color: var(--ink-soft);
}

/* ---------------------------------------------------------------- 표 */

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
th {
  text-align: left; font-size: 12px; font-weight: 800; color: var(--ink-faint);
  padding: 10px 8px; border-bottom: 1.5px solid var(--line); white-space: nowrap;
}
td { padding: 12px 8px; border-bottom: 1px solid #f1f5f9; font-weight: 600; }
tr:last-child td { border-bottom: none; }

.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.bar > i.hi { background: var(--ok); }
.bar > i.mid { background: var(--warn); }
.bar > i.lo { background: var(--bad); }

/* ---------------------------------------------------------------- 통계 타일 */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
@media (max-width: 640px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.tile .k { font-size: 12px; font-weight: 800; color: var(--ink-faint); margin-bottom: 4px; }
.tile .v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.tile .v small { font-size: 14px; color: var(--ink-faint); font-weight: 700; }

/* ---------------------------------------------------------------- 문항 (학생 화면) */

.qcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 14px; box-shadow: var(--shadow); }
.qcard .qtext { font-weight: 800; font-size: 16px; margin-bottom: 16px; display: block; }
.qcard .qtext .n { color: var(--brand); margin-right: 6px; }
.section-title {
  font-size: 18px; font-weight: 800; color: var(--brand);
  border-left: 5px solid var(--brand); padding-left: 12px; margin: 28px 0 12px;
}

.choices { display: grid; gap: 10px; }
.choice { display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .box {
  padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px;
  background: #fbfdff; font-weight: 700; color: var(--ink-soft); transition: all .12s;
}
.choice input:checked + .box { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }
.ox-row { display: flex; gap: 12px; }
.ox-row .choice { flex: 1; }
.ox-row .box { text-align: center; font-size: 26px; font-weight: 800; padding: 16px; }

.stars { display: flex; flex-direction: row-reverse; justify-content: center; gap: 4px; }
.stars input { display: none; }
.stars label { font-size: 34px; color: var(--line); cursor: pointer; line-height: 1; transition: color .1s; }
.stars input:checked ~ label,
.stars label:hover, .stars label:hover ~ label { color: #fbbf24; }

.preview { margin-top: 12px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); display: none; }
.preview.on { display: block; }
.preview img { width: 100%; display: block; }

/* ---------------------------------------------------------------- 편집기 */

.q-edit { border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; background: #fff; }
.q-edit.is-header { background: var(--brand-soft); border-color: #bfdbfe; }
.q-edit .head { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.q-edit .head .no { font-weight: 800; color: var(--brand); min-width: 34px; }
.q-edit .head .spacer { flex: 1; }
.q-edit .iconbtn {
  border: 1px solid var(--line); background: #fff; border-radius: 9px; cursor: pointer;
  width: 32px; height: 32px; font-size: 14px; color: var(--ink-soft); line-height: 1;
}
.q-edit .iconbtn:hover { background: var(--bg); color: var(--ink); }
.q-edit .iconbtn.del:hover { background: var(--bad-soft); color: var(--bad); border-color: #fecdd3; }
.opt-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.opt-row .pick { width: 20px; height: 20px; accent-color: var(--ok); flex: none; }
.type-pick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }

/* ---------------------------------------------------------------- QR 모달 */

.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal.on { display: flex; }
.modal .sheet { background: #fff; border-radius: 22px; padding: 32px; max-width: 400px; width: 100%; text-align: center; }
.qr-code { font-size: 30px; font-weight: 800; letter-spacing: .28em; margin: 16px 0 4px; }
#qrBox { display: flex; justify-content: center; }
#qrBox img, #qrBox canvas { max-width: 100%; height: auto; }

/* ---------------------------------------------------------------- 작품 벽 (피드) */
/* 문항이 세로 열로 늘어서고 좌우로 훑어본다 — pyo_wb 학생 피드와 같은 구조 */

body.wall-body { overflow: hidden; }
body.wall-body .wrap { max-width: none; padding: 0; }

.wall-head {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 10px 14px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.wall-head .wh-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.wall-head .wh-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.feed-badge {
  background: var(--brand); color: #fff; font-size: 10px; font-weight: 800;
  padding: 3px 7px; border-radius: 6px; letter-spacing: .04em;
}
.wh-title { font-size: 15px; font-weight: 800; }

#fontRange { width: 92px; accent-color: var(--brand); }

.feed-outer {
  height: calc(100vh - 52px);
  overflow-x: auto; overflow-y: hidden;
  padding: 16px 14px 20px;
  cursor: grab; user-select: none; -webkit-overflow-scrolling: touch;
  scrollbar-color: var(--ink-faint) var(--line);
}
.feed-outer:active { cursor: grabbing; }
.feed-outer::-webkit-scrollbar { height: 12px; }
.feed-outer::-webkit-scrollbar-track { background: var(--line); border-radius: 999px; }
.feed-outer::-webkit-scrollbar-thumb { background: var(--ink-faint); border-radius: 999px; }

.feed-inner { display: flex; flex-wrap: nowrap; gap: 14px; min-width: max-content; height: 100%; }

.q-column { width: 300px; flex: none; display: flex; flex-direction: column; height: 100%; }
.q-head {
  background: #fff; border: 1px solid var(--line); border-top: 4px solid var(--brand);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; flex: none;
}
.q-head .qn { color: var(--brand); font-weight: 800; }
.q-head .q-text { font-weight: 800; line-height: 1.4; }
.q-cards { overflow-y: auto; flex: 1; padding-right: 4px; }

.fcard {
  position: relative; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 12px; margin-bottom: 10px;
  transition: border-color .12s;
}
.fcard:hover { border-color: #bfdbfe; }
.fcard .who {
  font-size: 11px; font-weight: 800; color: var(--brand);
  border-bottom: 1px solid #f1f5f9; padding: 0 42px 5px 0; margin-bottom: 6px;
}
.fcard .who .grp { color: var(--ink-faint); font-weight: 700; }
.fcard .ans-text { color: var(--ink); line-height: 1.5; white-space: pre-wrap; }
.fcard .ans-text img { width: 100%; border-radius: 8px; margin-top: 4px; display: block; cursor: zoom-in; }
.fcard .none { color: var(--ink-faint); font-style: italic; }
.stars-view { color: #fbbf24; letter-spacing: 2px; }
.judge { margin-top: 6px; font-size: 11px; font-weight: 800; }
.judge.ok { color: var(--ok); }
.judge.no { color: var(--bad); }

.heart {
  position: absolute; top: 7px; right: 8px;
  border: 0; background: none; cursor: pointer; padding: 2px 4px;
  display: inline-flex; align-items: center; gap: 3px;
  color: var(--bad); font-size: 15px; line-height: 1;
}
.heart .cnt { font-size: 11px; font-weight: 800; }
.heart .ico { transition: transform .15s; }
.heart:active .ico { transform: scale(1.35); }
.heart.on .ico { animation: heartPop .3s ease-out; }
@keyframes heartPop { 0% { transform: scale(1); } 50% { transform: scale(1.4); } 100% { transform: scale(1); } }

.img-modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .82); z-index: 999;
  display: none; align-items: center; justify-content: center; padding: 20px; cursor: zoom-out;
}
.img-modal.on { display: flex; }
.img-modal img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* 폰에서는 한 문항씩 넘겨 본다 */
@media (max-width: 560px) {
  .q-column { width: 84vw; }
  .feed-outer { height: calc(100vh - 92px); padding: 12px 10px 16px; scroll-snap-type: x mandatory; }
  .q-column { scroll-snap-align: start; }
  .wall-head { padding: 8px 12px; gap: 8px; }
  .wh-title { font-size: 14px; }
  .wall-head .wh-right { width: 100%; margin-left: 0; }
}

/* ---------------------------------------------------------------- 작은 화면 대응 */

/* 한국어는 어절 단위로 끊고, 그래도 넘치면 강제로 줄바꿈 */
body { word-break: keep-all; overflow-wrap: anywhere; }

@media (max-width: 560px) {
  /* 메뉴가 여러 줄로 접히며 본문을 밀지 않게 옆으로 스크롤 */
  .topbar-inner { flex-wrap: nowrap; gap: 10px; }
  .topnav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .topnav a, .topnav .who { white-space: nowrap; flex: none; }
  .brand { font-size: 15px; white-space: nowrap; }
}

@media (max-width: 480px) {
  .wrap { padding: 16px 12px 80px; }
  h1 { font-size: 21px; line-height: 1.35; }
  h2 { font-size: 17px; }
  .sub { font-size: 14px; }
  .card { padding: 16px; }
  .qcard { padding: 16px; }
  .qcard .qtext { font-size: 15px; margin-bottom: 12px; line-height: 1.5; }
  .tile { padding: 13px; }
  .tile .v { font-size: 20px; }
  .tile .v small { font-size: 12px; }
  .stars label { font-size: 30px; }
  .ox-row .box { font-size: 22px; padding: 13px; }
  .choice .box { padding: 12px 13px; font-size: 15px; }
  .btn { padding: 10px 14px; }
  .btn.big { padding: 15px; font-size: 15px; }
  .item { padding: 14px; gap: 12px; }
  .item .grow { min-width: 0; }
  .item .acts { width: 100%; }
  .page-head .grow { min-width: 0; }
  .linkbox { font-size: 12px; }
}

@media print {
  body * { visibility: hidden; }
  #qrPrint, #qrPrint * { visibility: visible; }
  #qrPrint { position: absolute; inset: 0; margin: auto; }
  .modal { position: static; background: #fff; display: block; }
  .no-print { display: none !important; }
}
