/* ============================================================
 *  GAAT 시험 플랫폼 — 디자인 시스템 (틸/민트 · 학생 친화)
 * ============================================================ */
:root {
  --teal: #0d9488;          /* 주 색상 */
  --teal-dark: #0f766e;
  --teal-deep: #134e4a;     /* 진한 텍스트 */
  --mint: #ccfbf1;          /* 연한 배경 */
  --mint-soft: #f0fdfa;
  --amber: #f59e0b;         /* 포인트(등급 칩 등) */
  --text: #1f2937;
  --text-soft: #6b7280;
  --border: #d7e3e0;
  --red: #e11d48;
  --bg: #f4faf8;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Pretendard", "맑은 고딕", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  /* 한글이 어절 중간에서 끊기지 않도록(띄어쓰기 단위 줄바꿈) */
  word-break: keep-all;
  overflow-wrap: break-word;
}
/* 상속이 끊기는 폼 요소에도 동일 적용 */
input, textarea, select, button, table, th, td { word-break: keep-all; overflow-wrap: break-word; }
/* 긴 영문·URL·코드는 예외적으로 강제 줄바꿈 허용 */
.question-text, .result-output, .modal-body { overflow-wrap: anywhere; }
button { font-family: inherit; cursor: pointer; }
textarea, input { font-family: inherit; }

/* ---------- GAAT 로고(이미지 브랜딩) ---------- */
.brand-logo { display: block; margin: 0 auto; height: auto; max-width: 100%; }
.brand-logo.lg { width: 250px; margin-bottom: 10px; }   /* 입장 · 성적조회 (태그라인 포함) */
.brand-logo.md { width: 168px; margin-bottom: 8px; }    /* 응시자 정보 */
.brand-logo.xs { height: 26px; width: auto; display: inline-block; vertical-align: middle; }

/* (구) 텍스트 로고 — 이미지 미로드 시 폴백 */
.gaat-logo {
  font-size: 44px; font-weight: 900; letter-spacing: 2px; color: var(--teal-deep);
}
.gaat-logo span { color: var(--teal); }
.gaat-logo.sm { font-size: 30px; }
.gaat-logo.xs { font-size: 20px; letter-spacing: 1px; }

/* ---------- 공통 버튼 ---------- */
.btn {
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 700;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--mint-soft); border-color: var(--teal); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }

/* ---------- 등급 칩 ---------- */
.level-chip {
  display: inline-block;
  font-size: 12.5px; font-weight: 800;
  color: #92400e; background: #fef3c7; border: 1px solid #fcd34d;
  border-radius: 999px; padding: 2px 12px; vertical-align: middle;
}
.level-chip:empty { display: none; }

/* ============================================================
 *  게이트 화면 (시험코드 · 응시자 정보)
 * ============================================================ */
.gate-screen {
  position: fixed; inset: 0; z-index: 500;
  background: linear-gradient(160deg, #e6faf5 0%, #f2fbf8 55%, #eef7ff 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.gate-screen[hidden] { display: none; }
.gate-card {
  width: 100%; max-width: 400px;
  background: #fff; border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 18px 50px rgba(13, 148, 136, .13);
  padding: 38px 32px 30px; text-align: center;
}
.gate-brand { font-size: 15px; font-weight: 800; color: var(--teal-dark); margin-top: 2px; }
.gate-org { font-size: 12.5px; color: var(--text-soft); margin-bottom: 18px; }
.gate-sub { font-size: 14px; color: var(--text-soft); margin-bottom: 18px; line-height: 1.7; }
.gate-form { display: flex; flex-direction: column; gap: 12px; }
.gate-input {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 15px; text-align: center;
}
.gate-input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,148,136,.14); }
.gate-btn { padding: 13px; font-size: 15px; }
.gate-error { min-height: 20px; margin-top: 12px; font-size: 13px; color: var(--red); font-weight: 700; }
.gate-error.info-note { color: var(--teal-deep); font-weight: 600; }
.gate-input.locked { background: #f1f5f9; color: #334155; cursor: not-allowed; }
/* 법정대리인(보호자) 동의 — 만 14세 미만 */
.guardian-box {
  margin: 0 24px 20px; padding: 18px 20px;
  background: #fff7ed; border: 1.5px solid #fed7aa; border-radius: var(--radius);
}
.guardian-box h2 { font-size: 15.5px; color: #9a3412; margin-bottom: 8px; }
.guardian-lead { font-size: 14px; color: #7c2d12; line-height: 1.8; margin-bottom: 14px; }
.guardian-fields { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.guardian-fields .field { flex: 1; min-width: 200px; }
.guardian-box .gate-error { text-align: left; }

/* 동의 체크박스 그룹 · 개인정보 고지 */
.agree-group { display: flex; flex-direction: column; gap: 8px; }
.link-btn {
  background: none; border: none; padding: 0 0 0 4px; font-family: inherit; font-size: 13px;
  color: var(--teal); font-weight: 700; text-decoration: underline; cursor: pointer;
}
.privacy-body { line-height: 1.75; font-size: 14px; }
.privacy-lead { color: var(--text-soft); margin-bottom: 16px; }
.privacy-body h3 { font-size: 14.5px; color: var(--teal-deep); margin: 16px 0 6px; }
.privacy-body ul { margin: 0 0 0 18px; }
.privacy-body li { margin-bottom: 3px; }
.privacy-foot { margin-top: 18px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text-soft); font-size: 13px; }

.gate-link { display: inline-block; margin-top: 16px; font-size: 13px; color: var(--teal-deep); text-decoration: none; }
.gate-link:hover { text-decoration: underline; }
.gate-link b { color: var(--teal); }
.gate-link.foot-link { display: block; margin-top: 8px; font-size: 12px; color: var(--text-soft); }
.field { display: flex; flex-direction: column; gap: 5px; text-align: left; }
.field span { font-size: 13px; font-weight: 700; color: var(--teal-deep); }
.field em { color: var(--red); font-style: normal; }
.field .gate-input { text-align: left; }

/* ============================================================
 *  시험 안내
 * ============================================================ */
.intro-screen {
  position: fixed; inset: 0; z-index: 200;
  background: linear-gradient(160deg, #e6faf5 0%, #f2fbf8 100%);
  overflow-y: auto; padding: 40px 16px;
}
.intro-screen.hidden { display: none; }
.intro-card {
  margin: 0 auto; width: 100%; max-width: 860px;
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 12px 40px rgba(13, 148, 136, .12); overflow: hidden;
}
.intro-header {
  padding: 26px 34px 20px; border-bottom: 2px solid var(--mint);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand-line { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.brand-sub { font-size: 13.5px; font-weight: 700; color: var(--text-soft); }
.intro-header h1 { font-size: 25px; font-weight: 900; color: var(--teal-deep); }
.intro-examinee { font-size: 13.5px; color: var(--text-soft); text-align: right; line-height: 1.6; }
.intro-body { padding: 24px 34px 8px; }
.intro-section { margin-bottom: 24px; }
.intro-section h2 {
  font-size: 16.5px; font-weight: 800; color: var(--teal-dark);
  margin-bottom: 12px; padding-bottom: 7px; border-bottom: 2px solid var(--mint);
}
.notice-list { padding-left: 22px; }
.notice-list li { margin-bottom: 9px; font-size: 14.5px; }
.notice-warning {
  margin-top: 14px; text-align: center; color: var(--red); font-weight: 800; font-size: 14.5px;
  background: #fff1f2; border: 1px solid #fecdd3; border-radius: 8px; padding: 12px;
}
.faq-q { font-weight: 800; font-size: 14.5px; margin-bottom: 4px; color: var(--text); }
.faq-a { font-size: 14px; color: var(--teal-dark); margin-bottom: 12px; }
.intro-footer {
  padding: 18px 34px 26px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.intro-agree { font-size: 14.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.intro-agree input { width: 17px; height: 17px; accent-color: var(--teal); }
.intro-start { padding: 12px 34px; font-size: 15.5px; }

/* ============================================================
 *  시험 화면
 * ============================================================ */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 12px 22px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.examinee-name { font-size: 13.5px; font-weight: 700; color: var(--text-soft); }
.time-left {
  font-size: 14px; font-weight: 700; color: var(--teal-deep);
  background: var(--mint-soft); border: 1.5px solid var(--mint);
  border-radius: 10px; padding: 7px 14px;
}
.time-left strong { color: var(--teal-dark); }

.tab-nav { display: flex; background: #fff; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  flex: 1; min-width: 130px; border: none; background: none; padding: 12px 10px;
  font-size: 13.5px; font-weight: 700; color: var(--text-soft);
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tab.active { color: var(--teal-dark); border-bottom-color: var(--teal); background: var(--mint-soft); }

.step-nav {
  display: flex; justify-content: center; gap: 26px;
  background: var(--mint-soft); border-bottom: 1px solid var(--border); padding: 10px 12px 8px;
  overflow-x: auto;
}
.step { border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.step-label { font-size: 12px; font-weight: 700; color: var(--text-soft); }
.step-dot { width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 2px solid var(--border); }
.step.active .step-label { color: var(--teal-dark); }
.step.active .step-dot { background: var(--teal); border-color: var(--teal); }
.step.done .step-dot { background: var(--mint); border-color: var(--teal); }

.exam-body {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px 18px 26px;
  max-width: 1500px; margin: 0 auto; width: 100%;
}
@media (max-width: 980px) { .exam-body { grid-template-columns: 1fr; } }

.left-panel, .right-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.question-box {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; max-height: 46vh; overflow-y: auto;
}
.question-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.question-title { font-size: 16.5px; font-weight: 800; color: var(--teal-dark); }
.subject-badges { display: flex; gap: 5px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.subject-badge {
  font-size: 11.5px; font-weight: 800; color: var(--teal-deep);
  background: var(--mint); border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
.question-text { font-size: 14.5px; white-space: pre-wrap; }
.question-file { }
.dl-file {
  display: inline-block; font-size: 13.5px; font-weight: 700; color: var(--teal-dark);
  background: #fff; border: 1.5px dashed var(--teal); border-radius: 10px; padding: 9px 15px;
  text-decoration: none;
}
.dl-file:hover { background: var(--mint-soft); }

.answer-block { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.answer-label { font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.answer-label .required { color: var(--red); font-size: 12.5px; }
.answer-guide { font-size: 12.5px; color: var(--teal-dark); margin-bottom: 8px; }
.answer-input {
  width: 100%; min-height: 120px; resize: vertical;
  border: 1.5px solid var(--border); border-radius: 10px; padding: 11px 13px; font-size: 14px;
}
.answer-input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,148,136,.12); }
.answer-file { font-size: 13.5px; }
.answer-image-preview img { max-width: 100%; border-radius: 10px; margin-top: 10px; border: 1px solid var(--border); }
.choice-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.choice-option {
  display: flex; gap: 9px; align-items: flex-start; border: 1.5px solid var(--border);
  border-radius: 10px; padding: 11px 13px; font-size: 14px; cursor: pointer;
}
.choice-option.selected { border-color: var(--teal); background: var(--mint-soft); }
.choice-option input { margin-top: 3px; accent-color: var(--teal); }

.left-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.left-actions .btn { flex: 1; min-width: 90px; }

/* ---------- 우측 AI 패널 ---------- */
.model-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.model-box {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px 12px;
}
.model-box legend { font-size: 12.5px; font-weight: 800; color: var(--teal-dark); padding: 0 5px; }
.model-box:disabled { opacity: .45; }
.radio { display: block; font-size: 13.5px; padding: 3px 0; }
.radio input { accent-color: var(--teal); margin-right: 5px; }
.mode-hint { font-size: 12.5px; color: var(--teal-dark); padding: 0 3px; min-height: 18px; }
.mode-hint-notice { background: #fef9e7; border: 1px solid #fcd34d; border-radius: 8px; padding: 9px 12px; color: #92400e; }

.prompt-box, .result-box { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.prompt-head, .result-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; font-size: 14px; font-weight: 800; color: var(--text); }
.token-count { font-size: 12.5px; color: var(--text-soft); font-weight: 700; }
.token-count strong { color: var(--teal-dark); }
.prompt-input {
  width: 100%; min-height: 130px; resize: vertical;
  border: 1.5px solid var(--border); border-radius: 10px; padding: 11px 13px; font-size: 14px;
}
.prompt-input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,148,136,.12); }
.prompt-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.prompt-actions > div { display: flex; gap: 8px; }
.result-head { font-weight: 800; }
.result-output { min-height: 140px; max-height: 40vh; overflow-y: auto; font-size: 14px; white-space: pre-wrap; color: var(--text); background: var(--mint-soft); border-radius: 10px; padding: 12px 14px; }
.result-output:empty::before { content: "AI 응답 결과가 여기에 표시됩니다."; color: #9aa9a5; }
.result-output.loading::before { content: "AI가 답변을 생성하는 중입니다…"; color: var(--teal-dark); }
.result-images { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.result-images:empty { display: none; }
.result-images figure { margin: 0; }
.result-images img { max-width: 100%; border-radius: 10px; border: 1px solid var(--border); }
.result-images .dl { display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 700; color: var(--teal-dark); }
.img-status { font-size: 13.5px; color: var(--teal-dark); }
.img-error { font-size: 13.5px; color: var(--red); font-weight: 700; }
.result-actions { margin-top: 10px; text-align: right; }
.playground-disabled { opacity: .55; pointer-events: none; }

/* ---------- 모달 ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300; background: rgba(19, 78, 74, .45);
  display: flex; align-items: center; justify-content: center; padding: 22px;
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  width: 100%; max-width: 760px; max-height: 86vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 16px; overflow: hidden;
}
.modal-header { display: flex; align-items: center; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 17px; font-weight: 800; color: var(--teal-deep); flex: 1; }
.modal-progress { font-size: 13px; font-weight: 700; color: var(--teal-dark); }
.modal-close { border: none; background: none; font-size: 26px; color: var(--text-soft); line-height: 1; }
.modal-body { padding: 16px 22px; overflow-y: auto; }
.modal-footer { padding: 12px 22px; border-top: 1px solid var(--border); text-align: right; }

.answer-item { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.answer-item-head { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.answer-item-no { font-weight: 900; color: var(--teal-dark); }
.answer-item-title { flex: 1; font-weight: 700; font-size: 14px; }
.answer-badge { font-size: 11.5px; font-weight: 800; border-radius: 999px; padding: 2px 10px; }
.answer-badge.done { color: #065f46; background: #d1fae5; }
.answer-badge.todo { color: #9f1239; background: #ffe4e6; }
.answer-field { margin-bottom: 8px; }
.answer-field-label { font-size: 12.5px; font-weight: 800; color: var(--text-soft); margin-bottom: 3px; }
.answer-field-value { font-size: 13.5px; white-space: pre-wrap; background: var(--mint-soft); border-radius: 8px; padding: 9px 11px; }
.answer-field-value.empty { color: #9aa9a5; }
.answer-field-img { max-width: 220px; border-radius: 8px; border: 1px solid var(--border); }
.answer-goto { border: none; background: none; color: var(--teal-dark); font-size: 13px; font-weight: 800; padding: 0; }

.log-item { border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; margin-bottom: 10px; }
.log-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12.5px; }
.log-idx { font-weight: 900; color: var(--text-soft); }
.log-type { font-weight: 800; border-radius: 999px; padding: 1px 9px; font-size: 11.5px; }
.log-type.txt { color: var(--teal-deep); background: var(--mint); }
.log-type.img { color: #7c2d12; background: #ffedd5; }
.log-model { font-weight: 700; color: var(--text-soft); }
.log-time { margin-left: auto; color: #9aa9a5; }
.log-prompt { font-size: 13px; white-space: pre-wrap; max-height: 90px; overflow-y: auto; background: var(--mint-soft); border-radius: 8px; padding: 8px 10px; }
.log-usage { font-size: 12px; color: var(--text-soft); margin-top: 5px; }
.log-empty { text-align: center; color: var(--text-soft); padding: 26px 0; font-size: 14px; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%) translateY(16px);
  background: var(--teal-deep); color: #fff; font-size: 14px; font-weight: 700;
  border-radius: 999px; padding: 11px 22px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 700;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
