:root {
  --brand: #1e3a8a;
  --brand-2: #2563eb;
  --brand-soft: #eff4ff;
  --ink: #111827;
  --ink-2: #4b5563;
  --ink-3: #9ca3af;
  --line: #e5e7eb;
  --bg: #f6f7fb;
  --card: #ffffff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
a { color: var(--brand-2); }
h1, h2, h3 { margin: 0; line-height: 1.3; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0; }
small, .muted { color: var(--ink-2); font-size: 13px; }

/* 레이아웃 */
.wrap { max-width: 880px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 420px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

/* 상단바 */
.topbar { background: var(--brand); color: #fff; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
.topbar .title { font-weight: 700; font-size: 16px; }
.topbar .who { font-size: 13px; opacity: .9; }
.topbar button { background: rgba(255, 255, 255, .15); color: #fff; border: 0; }

/* 카드 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }

/* 탭 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 4px 0 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 14px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

/* 폼 */
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field + .field { margin-top: 14px; }
.hint { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  border: 1px solid #d1d5db; border-radius: 10px; padding: 10px 12px; background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: transparent; }

/* 버튼 */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 10px; padding: 9px 14px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.danger { color: var(--bad); }
.ghost { background: transparent; border-color: transparent; color: var(--ink-2); padding: 6px 8px; }
.big { width: 100%; justify-content: center; padding: 13px 16px; font-size: 16px; }
.icon { padding: 6px 9px; min-width: 34px; justify-content: center; }

/* 배지 */
.badge { display: inline-block; flex: none; white-space: nowrap; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #f3f4f6; color: var(--ink-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.new { background: var(--bad); color: #fff; }

/* 안내 상자 */
.note { border-radius: 10px; padding: 10px 12px; font-size: 13.5px; background: var(--brand-soft); color: var(--brand); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.ok { background: var(--ok-soft); color: var(--ok); }

/* 링크 상자 */
.linkbox { display: flex; gap: 8px; align-items: center; background: #f9fafb; border: 1px dashed #cbd5e1; border-radius: 10px; padding: 8px 10px; }
.linkbox code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

/* 문항 목록 */
.qlist { list-style: none; margin: 0; padding: 0; }
.qitem { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.qitem:first-child { border-top: 0; }
.qno { flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-weight: 700; display: grid; place-items: center; }
.qbody { flex: 1; min-width: 0; }
.qtext { white-space: pre-wrap; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qthumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex: none; }
.qactions { display: flex; gap: 4px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

/* 레벨 기준 */
.lvrow { display: grid; grid-template-columns: 90px 1fr 34px; gap: 8px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.lvrow:first-of-type { border-top: 0; }
.lvrow .range { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-2); }
.lvrow textarea { min-height: 44px; }

/* 대화상자 */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(17, 24, 39, .45); }
dialog form { padding: 20px; overflow-y: auto; max-height: calc(100vh - 24px); }
.choice-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; }
.choice-row + .choice-row { margin-top: 8px; }
.choice-row b { text-align: center; }
.choice-row .ans { font-weight: 500; font-size: 13px; display: flex; gap: 4px; align-items: center; margin: 0; white-space: nowrap; }
.imgprev { max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); display: block; margin-top: 8px; }

/* 응시 결과 목록 */
.rtools { display: flex; gap: 8px; margin-bottom: 8px; }
.rtools input { flex: 1; min-width: 0; }
.rtools select { width: auto; flex: none; max-width: 42%; }
.rlist { list-style: none; margin: 0; padding: 0; }
.rlist li + li { border-top: 1px solid var(--line); }
.ritem { display: flex; width: 100%; gap: 12px; align-items: center; justify-content: space-between; text-align: left; border: 0; border-radius: 10px; padding: 12px 8px; background: none; font-weight: 400; }
.ritem:hover { background: #f9fafb; }
.ritem.is-new { background: #fff7f7; }
.rmain { flex: 1; min-width: 0; }
.rname { font-weight: 700; font-size: 16px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rsub { font-size: 13px; color: var(--ink-2); margin-top: 3px; display: flex; gap: 6px; align-items: center; min-width: 0; }
.rmemo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rscore { flex: none; text-align: right; font-size: 15px; }
.rscore small { font-size: 12.5px; }
.rlevel { font-size: 13px; font-weight: 700; color: var(--brand); margin-top: 3px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rteacher { color: var(--brand); font-size: 12.5px; flex: none; }

/* 원장: 선생님 목록 */
.tlist { list-style: none; margin: 0; padding: 0; }
.titem { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.titem:first-child { border-top: 0; }
.titem.off .tmain { opacity: .6; }
.tmain { flex: 1; min-width: 0; }
.titem > button, .titem > small { flex: none; }

/* 응시 결과 상세 */
.rhead { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.rhead a { font-size: 17px; font-weight: 700; text-decoration: none; }
.rsummary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.rsummary > div { background: var(--brand-soft); border-radius: 10px; padding: 10px; text-align: center; min-width: 0; }
.rsummary small { display: block; }
.rsummary b { font-size: 17px; color: var(--brand); overflow-wrap: anywhere; }
#rForm .field { margin-top: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 10px 16px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand-2); color: #fff; }
.olist { list-style: none; margin: 8px 0 0; padding: 0; }
.oitem { display: flex; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.omark { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.oitem.o .omark { background: var(--ok-soft); color: var(--ok); }
.oitem.x .omark { background: var(--bad-soft); color: var(--bad); }
.obody { flex: 1; min-width: 0; }
.otitle { font-size: 12.5px; color: var(--ink-2); font-weight: 700; }
.otext { white-space: pre-wrap; margin-top: 2px; }
.oimg { display: block; max-width: 100%; max-height: 220px; border-radius: 8px; border: 1px solid var(--line); margin-top: 6px; }
.oans { margin-top: 6px; font-size: 14px; display: grid; gap: 2px; }
.oitem.x .oans > div:first-child { color: var(--bad); }
.oitem.x .oans > div:last-child { color: var(--ok); }

/* 알림 */
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 14px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); }
.toast-error { background: var(--bad); }

.center { text-align: center; }
.spacer { height: 8px; }
.empty { text-align: center; color: var(--ink-3); padding: 28px 0; }
.loading { text-align: center; color: var(--ink-3); padding: 60px 0; }

@media (max-width: 560px) {
  .wrap { padding: 12px; }
  .card { padding: 14px; }
  .qthumb { display: none; }
  .qitem { flex-wrap: wrap; }
  .qactions { width: 100%; justify-content: flex-start; padding-left: 42px; }
}
