/* ==========================================================
 * doseapply 공통 스타일
 * 미니멀 · 절제된 모노톤 디자인
 * ========================================================== */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #fafbfc;
  --border: #e7e9ee;
  --border-strong: #d6d9e0;
  --text: #191c22;
  --text-secondary: #565c68;
  --text-muted: #8a909c;
  --accent: #1f2430;
  --accent-hover: #2c3444;
  --danger: #b23b3b;
  --danger-hover: #c04747;
  --success: #2f7d59;
  --amber: #9a7016;
  --discord: #5865f2;
  --focus: rgba(31, 36, 48, 0.35);

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-xs: 0 1px 2px rgba(20, 24, 33, 0.05);
  --shadow-sm: 0 1px 3px rgba(20, 24, 33, 0.06), 0 1px 2px rgba(20, 24, 33, 0.04);
  --shadow-md: 0 4px 16px rgba(20, 24, 33, 0.08);
  --shadow-lg: 0 12px 40px rgba(20, 24, 33, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 15px;
}

body {
  margin: 0;
  font-family: "Pretendard", "Pretendard Variable", -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- 상단 바 ---------- */
.topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar .brand {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.topbar .brand:hover {
  text-decoration: none;
}

.topbar .brand small {
  font-weight: 500;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: 8px;
  letter-spacing: 0;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.userbox img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
}

.userbox .logout-link {
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.82rem;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.userbox .logout-link:hover {
  color: var(--text);
  background: var(--bg);
}

/* ---------- 레이아웃 ---------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 36px 20px 80px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 8px 0 6px;
  padding: 0;
  border: none;
}

.page-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 28px;
}

/* ---------- 박스/패널 ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-head {
  padding: 14px 18px;
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
}

.panel-body {
  padding: 18px;
}

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-muted);
  border-color: var(--text-muted);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-danger {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--danger);
}

.btn-danger:hover {
  background: #fdf3f3;
  border-color: var(--danger);
}

.btn-discord {
  background: var(--discord);
  border-color: var(--discord);
  color: #fff;
  font-weight: 600;
  padding: 12px 22px;
  width: 100%;
}

.btn-discord:hover {
  background: #4b57df;
  border-color: #4b57df;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* ---------- 입력 ---------- */
input[type="text"],
input[type="number"],
textarea,
select {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.55;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

.form-row {
  margin-bottom: 16px;
}

.form-inline {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-inline > div {
  flex: 1;
  min-width: 140px;
}

.checkbox-label {
  font-weight: 500;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ---------- 표 ---------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.87rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

th, td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.12s;
}

tbody tr:hover td {
  background: var(--surface-muted);
}

/* ---------- 뱃지/상태 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge-green { color: var(--success); background: #eaf4ee; }
.badge-gray  { color: var(--text-secondary); background: #eef0f3; }
.badge-red   { color: var(--danger); background: #fbecec; }
.badge-amber { color: var(--amber); background: #f9f0dc; }

/* ---------- 알림 ---------- */
.notice {
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  margin-bottom: 16px;
}

.notice-info  { background: #eef1f6; color: #2f3a4d; border-color: #dde3ec; }
.notice-warn  { background: #f9f0dc; color: #6f5210; border-color: #efe0be; }
.notice-error { background: #fbecec; color: #8a2e2e; border-color: #f0d5d5; }

.empty-message {
  color: var(--text-muted);
  font-size: 0.88rem;
  padding: 40px 0;
  text-align: center;
}

/* ---------- 로그인 화면 ---------- */
.login-wrap {
  max-width: 400px;
  margin: 88px auto 0;
  text-align: center;
  padding: 0 20px;
}

.login-logo {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.login-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 32px 28px;
  text-align: left;
}

.login-divider {
  margin: 24px 0 18px;
  border: none;
  border-top: 1px solid var(--border);
}

.local-login-note {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.local-login-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.local-login-form input {
  flex: 1 1 auto;
  min-width: 0;
}

.local-login-form .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* ---------- 시험 목록 ---------- */
.exam-list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  padding: 18px 20px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.exam-list-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.exam-list-item h3 {
  margin: 0 0 4px;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.exam-list-item .meta {
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ---------- 시험 응시 화면 ---------- */
.exam-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.exam-header .exam-title {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.exam-timer {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 5px 14px;
}

.exam-timer.warning {
  color: var(--danger);
  border-color: var(--danger);
  background: #fbecec;
}

.monitor-indicator {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.monitor-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(47, 125, 89, 0.15);
}

.monitor-dot.off {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(178, 59, 59, 0.15);
}

.question-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  margin-bottom: 16px;
  overflow: hidden;
}

.question-block .q-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.question-block .q-head .q-points {
  float: right;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.question-block .q-body {
  padding: 18px;
}

.q-text {
  margin: 0 0 16px;
  white-space: pre-wrap;
  font-size: 0.98rem;
  line-height: 1.6;
}

/* 지문 (문제와 선지 사이의 제시문) */
.q-passage {
  white-space: pre-wrap;
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 0 0 16px;
}

.choice {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 0.92rem;
  background: var(--surface);
  transition: border-color 0.12s, background 0.12s;
}

.choice:hover {
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

.choice.selected {
  border-color: var(--accent);
  background: #f0f1f4;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.choice input {
  margin-right: 11px;
  accent-color: var(--accent);
}

/* 번호 택1 (numeric) */
.numeric-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.numeric-choice {
  position: relative;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  transition: border-color 0.12s, background 0.12s, color 0.12s;
  user-select: none;
}

.numeric-choice:hover {
  border-color: var(--text-muted);
  background: var(--surface-muted);
}

.numeric-choice input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.numeric-choice.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* 단답식 */
.short-answer {
  max-width: 340px;
}

/* 서술식 */
.long-answer {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  line-height: 1.6;
}

.exam-footer {
  text-align: center;
  padding: 24px 0 48px;
}

.warn-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  max-width: 320px;
  background: var(--accent);
  color: #fff;
  padding: 14px 18px;
  font-size: 0.87rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
  animation: toast-in 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.warn-toast.show {
  display: block;
}

/* 응시 전 안내 화면 */
.exam-intro {
  max-width: 620px;
  margin: 48px auto;
}

.exam-intro ul {
  padding-left: 20px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.exam-intro li {
  margin-bottom: 7px;
}

/* ---------- 결과 화면 ---------- */
.result-score {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  text-align: center;
  margin: 12px 0 4px;
}

.result-detail {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* ---------- 관리자 ---------- */
.admin-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.admin-tabs button {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 11px 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
}

.admin-tabs button:hover {
  color: var(--text);
}

.admin-tabs button.active {
  color: var(--text);
  font-weight: 600;
}

.admin-tabs button.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.question-editor {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 16px;
  margin-bottom: 14px;
}

.question-editor .qe-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.question-editor .qe-head strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.choice-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.choice-row input[type="radio"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.choice-row input[type="text"] {
  flex: 1;
}

.choice-row .remove-choice {
  flex-shrink: 0;
}

.hint-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 감시 리포트 상세 */
.proctor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.proctor-cell {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 12px 14px;
}

.proctor-cell .k {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.proctor-cell .v {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.suspicion-bar-wrap {
  background: var(--border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin: 8px 0 16px;
}

.suspicion-bar {
  height: 100%;
  background: var(--success);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.suspicion-bar.mid { background: var(--amber); }
.suspicion-bar.high { background: var(--danger); }

.flag-list {
  margin: 0;
  padding-left: 20px;
  font-size: 0.87rem;
  color: var(--danger);
}

.event-log {
  max-height: 240px;
  overflow-y: auto;
  font-family: "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.76rem;
  background: #14161b;
  color: #c4c8d0;
  padding: 14px;
  border-radius: var(--radius-sm);
  line-height: 1.7;
}

.event-log .lt { color: #7d93b8; }

/* ---------- 모달 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 33, 0.5);
  backdrop-filter: blur(2px);
  z-index: 300;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 20px;
  overflow-y: auto;
}

.modal-backdrop.show {
  display: flex;
  animation: fade-in 0.18s ease;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 720px;
  width: 100%;
  overflow: hidden;
  animation: modal-in 0.22s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}

.modal-head button:hover {
  color: var(--text);
}

.modal-body {
  padding: 20px;
  max-height: 72vh;
  overflow-y: auto;
}

/* ---------- 푸터 ---------- */
.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 32px 0;
  margin-top: 48px;
}

.container > .footer {
  border-top: 1px solid var(--border);
}

/* ---------- 반응형 ---------- */
@media (max-width: 600px) {
  html { font-size: 14px; }
  .exam-header { position: static; }
  .form-inline {
    flex-direction: column;
    gap: 0;
  }
  .container { padding: 24px 16px 60px; }
}