/* ============================================================
   학업 생활 진단 — 앱 고유 스타일 (수석의방 공용 토큰 사용)
   공용 셸/챗/기록 클래스는 shared/layout.css 를 그대로 사용.
   로드 순서: variables.css → base.css → layout.css → app.css
   ============================================================ */

/* ===== 부팅 화면 ===== */
.boot-screen {
  display: flex; align-items: center; justify-content: center;
  height: 100dvh; color: var(--soft); font-size: .9rem;
}

/* ===== 유틸 & 애니메이션 ===== */
.hidden { display: none !important; }
.fade-in { animation: fadeIn .4s ease; }
.slide-up { animation: slideUp .45s ease; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px) } to { opacity: 1; transform: translateY(0) } }
@keyframes bounce { 0%, 100% { transform: translateY(0) } 50% { transform: translateY(-4px) } }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .5 } }
@keyframes spin { to { transform: rotate(360deg) } }
.hl { color: var(--brand); }

/* ===== .app-main 내부 스크롤 영역 ===== */
.step-scroll { padding: 24px 20px; }
.step-center { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100vh - 120px); }

/* 상단 네비 (뒤로 / 처음으로 / 단어 목록) */
.step-back {
  flex: 0 0 auto; align-self: flex-start; margin: 0; padding: 12px 20px 2px;
  background: none; border: none; color: var(--soft); font-size: .82rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px; transition: color .15s;
}
.step-back:hover { color: var(--mute); }

.step-title { display: flex; align-items: center; gap: .5rem; font-size: 1.1rem; margin-bottom: 1.1rem; }
.step-title .badge {
  width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: .72rem; font-weight: 700; flex: 0 0 auto;
}

/* ===== 입력 카드 (인트로/성찰/정리 공통) ===== */
.input-card { max-width: 30rem; width: 100%; }
.input-card .icon-circle {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  margin-bottom: 1rem; background: var(--brand-tint); color: var(--brand);
}
.input-card h2 { font-size: 1.25rem; margin-bottom: .5rem; }
.input-card .desc { font-size: .88rem; color: var(--soft); line-height: 1.65; margin-bottom: 1.1rem; }
.input-card .textarea { min-height: 8rem; }
.submit-btn { display: flex; width: 100%; margin-top: 1rem; }
.char-info { display: flex; justify-content: space-between; font-size: .74rem; margin-top: 6px; font-weight: 600; }
.char-ok { color: var(--green); }
.char-warn { color: var(--amber); }
.char-default { color: var(--soft); }

/* ===== 진단 안내/결과 카드 ===== */
.notice-line { font-size: .78rem; color: var(--soft); margin-top: 12px; text-align: center; line-height: 1.6; }
.brand-eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .08em; color: var(--brand); text-transform: none; margin-bottom: 6px; }

/* ===== 학생 정보 폼 ===== */
.sf-fields { display: flex; flex-direction: column; gap: 16px; margin: 18px 0 8px; }
.sf-field-label { display: block; font-size: .8rem; font-weight: 700; color: var(--mute); margin-bottom: 6px; }
.grade-row { display: flex; flex-wrap: wrap; gap: 8px; }
.grade-btn {
  padding: 9px 14px; border-radius: 50px; font-size: .84rem; font-weight: 600;
  background: #fff; color: var(--soft); border: 1.5px solid var(--border-neutral); transition: all .15s;
}
.grade-btn:hover { border-color: var(--brand-l); }
.grade-btn.selected { background: var(--brand); color: #fff; border-color: var(--brand); }
.sf-error { color: var(--red); font-size: .82rem; margin-top: 10px; font-weight: 600; }

/* ===== 설문 ===== */
.survey-head { text-align: center; margin-bottom: 18px; }
.survey-head h2 { font-size: 1.3rem; margin-bottom: .3rem; }
.survey-head p { color: var(--soft); font-size: .84rem; }
.survey-progress-box { max-width: 560px; width: 100%; margin: 0 auto 20px; }
.survey-prog-meta { display: flex; justify-content: space-between; font-size: .76rem; color: var(--soft); font-weight: 600; margin-bottom: 6px; }
.survey-bar-track { height: 8px; background: var(--border-neutral); border-radius: 50px; overflow: hidden; }
.survey-bar-fill { height: 100%; background: var(--brand); border-radius: 50px; transition: width .3s ease; }

.survey-qs { max-width: 620px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.survey-q-item {
  background: var(--bg-surface-white); border: 1px solid var(--border-neutral); border-radius: 16px;
  padding: 20px 18px 16px; box-shadow: var(--shadow-sm); transition: opacity .25s, border-color .2s;
}
.survey-q-item.answered { border-color: var(--brand-l); }
.survey-q-item.dim { opacity: .5; }
.survey-q-text { font-size: .96rem; font-weight: 600; color: var(--ink); text-align: center; word-break: keep-all; line-height: 1.5; }

.survey-scale-container { display: flex; flex-direction: column; align-items: center; width: 100%; margin-top: 16px; }
.survey-scale-row { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 460px; position: relative; padding: 8px 0; }
.survey-scale-row::before {
  content: ''; position: absolute; top: 50%; left: 22px; right: 22px; height: 2px;
  background: var(--border-neutral); transform: translateY(-50%); z-index: 1;
}
.sc {
  background: #fff; border-radius: 50%; cursor: pointer; position: relative; z-index: 2;
  transition: all .28s cubic-bezier(.175, .885, .32, 1.275); box-shadow: 0 2px 6px rgba(0, 0, 0, .04); padding: 0;
}
.sc.sc-1, .sc.sc-7 { width: 44px; height: 44px; }
.sc.sc-2, .sc.sc-6 { width: 36px; height: 36px; }
.sc.sc-3, .sc.sc-5 { width: 28px; height: 28px; }
.sc.sc-4 { width: 22px; height: 22px; }
/* 왼쪽 3개 = 아니다 (red) */
.sc.sc-1, .sc.sc-2, .sc.sc-3 { border: 3px solid var(--red); }
.sc.sc-1:hover, .sc.sc-2:hover, .sc.sc-3:hover { transform: scale(1.15); box-shadow: 0 0 10px rgba(184, 48, 48, .22); }
.sc.sc-1.on, .sc.sc-2.on, .sc.sc-3.on { background: var(--red); border-color: var(--red); transform: scale(1.1); box-shadow: 0 0 12px rgba(184, 48, 48, .4); }
/* 가운데 = 보통 (neutral) */
.sc.sc-4 { border: 3px solid var(--soft); }
.sc.sc-4:hover { transform: scale(1.15); box-shadow: 0 0 8px rgba(107, 107, 107, .2); }
.sc.sc-4.on { background: var(--soft); border-color: var(--soft); transform: scale(1.1); box-shadow: 0 0 10px rgba(107, 107, 107, .3); }
/* 오른쪽 3개 = 그렇다 (green) */
.sc.sc-5, .sc.sc-6, .sc.sc-7 { border: 3px solid var(--green); }
.sc.sc-5:hover, .sc.sc-6:hover, .sc.sc-7:hover { transform: scale(1.15); box-shadow: 0 0 10px rgba(46, 125, 82, .22); }
.sc.sc-5.on, .sc.sc-6.on, .sc.sc-7.on { background: var(--green); border-color: var(--green); transform: scale(1.1); box-shadow: 0 0 12px rgba(46, 125, 82, .4); }
.survey-scale-labels { display: flex; justify-content: space-between; width: 100%; max-width: 460px; margin-top: 12px; font-size: .78rem; font-weight: 700; color: var(--soft); line-height: 1.35; }
.survey-scale-labels .text-right { text-align: right; }
.survey-scale-labels .mid { color: var(--soft); align-self: center; }

.survey-nav { max-width: 620px; width: 100%; margin: 22px auto 4px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.survey-nav .btn { white-space: nowrap; flex-shrink: 0; padding: 10px 18px; font-size: .88rem; line-height: 1.2; }
.survey-dots { display: flex; gap: 5px; flex-shrink: 1; overflow: hidden; }
.survey-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-neutral); flex-shrink: 0; }
.survey-dot.cur { background: var(--brand); transform: scale(1.2); }
.survey-dot.past { background: var(--brand-l); }
.auto-fill-btn {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .78rem; font-weight: 700; color: var(--brand-d);
  background: var(--brand-tint); border: 1.5px solid rgba(0, 82, 204, 0.2);
  border-radius: 50px; padding: 5px 12px; cursor: pointer;
  transition: all 0.15s ease; box-shadow: var(--shadow-sm); flex-shrink: 0;
}
.auto-fill-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.auto-fill-btn:active { transform: scale(0.97); }

/* ===== 랜딩 ===== */
.landing-head { text-align: center; max-width: 720px; margin: 0 auto 22px; }
.landing-head h1 { font-size: 1.5rem; margin-bottom: .5rem; }
.landing-head p { color: var(--soft); font-size: .9rem; line-height: 1.7; }
.landing-head strong { color: var(--brand-d); font-weight: 700; }

.landing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; max-width: 900px; margin: 0 auto; }
.landing-card {
  background: var(--bg-surface-white); padding: 18px; border-radius: 16px; border: 1px solid var(--border-neutral);
  text-align: left; cursor: pointer; transition: all .18s; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 8px; position: relative;
}
.landing-card:hover { box-shadow: var(--shadow-md); border-color: var(--brand-l); transform: translateY(-2px); }
.landing-card:active { transform: scale(.98); }
.card-badge {
  font-size: .64rem; font-weight: 800; letter-spacing: .03em; padding: .2rem .55rem; border-radius: 6px;
  background: var(--brand-tint); color: var(--brand); width: fit-content;
}
.card-badge.weak { background: #fbeeee; color: var(--red); }
.card-title { font-size: 1.1rem; font-weight: 700; color: var(--ink); }
.card-desc { font-size: .8rem; color: var(--soft); line-height: 1.55; flex: 1; }
.card-status { font-size: .78rem; font-weight: 700; color: var(--brand); margin-top: 4px; }
.card-status.completed { color: var(--green); }

/* ===== 만다라트 9x9 차트 (블루 시스템 재테마) ===== */
.mandalart-container {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0;
  width: 100%; max-width: 540px; margin: 0 auto 14px;
  border: 1.5px solid var(--border-neutral); border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.mandalart-box { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-right: 2px solid #d3d7de; border-bottom: 2px solid #d3d7de; }
.mandalart-box:nth-child(3n) { border-right: none; }
.mandalart-box:nth-child(n+7) { border-bottom: none; }
.mandalart-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 500; padding: 2px; text-align: center;
  background: #fff; color: var(--mute); line-height: 1.2; word-break: keep-all;
  border-right: 1px solid var(--border-neutral); border-bottom: 1px solid var(--border-neutral);
}
.mandalart-cell:nth-child(3n) { border-right: none; }
.mandalart-cell:nth-child(n+7) { border-bottom: none; }
.mandalart-cell.cell-hub { background: #dcdcdc; color: #444444; font-weight: 700; font-size: 11px; border: 1px solid #c8c8c8; }
.mandalart-cell.cell-core { background: #a6a6a6; color: #ffffff; font-weight: 800; font-size: 12.5px; border: 2px solid #8e8e8e; }

.mandalart-legend { display: flex; align-items: center; justify-content: center; gap: 10px; max-width: 540px; margin: 0 auto 26px; font-size: .74rem; color: var(--soft); font-weight: 600; }
.mandalart-legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; vertical-align: middle; margin-right: 4px; }
.mandalart-legend .dot.weak { background: #0041A3; }
.mandalart-legend .dot.strong { background: #ffffff; border: 1px solid var(--border-neutral); }
.mandalart-legend .bar { flex: 1; max-width: 180px; height: 8px; border-radius: 4px; border: 1px solid var(--border-neutral); background: linear-gradient(to right, #0041A3 0%, #7d9ed0 50%, #ffffff 100%); }

/* ===== 채팅 (공용 chat-log/msg-* 위에 얹는 요소) ===== */
.chat-badge { display: flex; justify-content: center; padding: 4px 0 6px; }
.chat-badge-inner { background: var(--bg-surface-white); border: 1px solid var(--border-neutral); border-radius: 14px; padding: .45rem 1.3rem; text-align: center; box-shadow: var(--shadow-sm); }
.chat-badge-inner .mode-label { font-size: .62rem; font-weight: 800; letter-spacing: .04em; color: var(--brand); }
.chat-badge-inner h3 { font-size: 1.02rem; font-weight: 700; color: var(--ink); }
.typing-dots { display: flex; gap: 4px; align-items: center; padding: 2px 0; }
.typing-dots span { width: 6px; height: 6px; background: var(--soft); border-radius: 50%; animation: bounce .6s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .1s; }
.typing-dots span:nth-child(3) { animation-delay: .2s; }
.chat-progress { display: flex; justify-content: space-between; align-items: center; padding: 8px 18px; font-size: .74rem; font-weight: 600; background: var(--bg-page); border-top: 1px solid var(--border-neutral); }
.chat-progress .label { color: var(--soft); }
.turn-dots { display: flex; gap: 5px; }
.turn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-neutral); }
.turn-dot.filled { background: var(--brand); }
.chat-done-acts { flex: 0 0 auto; display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border-neutral); background: var(--bg-surface-white); }
.chat-done-acts .btn { flex: 1; }
.chat-send svg.spin { animation: spin .8s linear infinite; }

/* ===== 정의/중요성 리빌 ===== */
.reveal-block { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.reveal-line { background: var(--bg-surface-white); border: 1px solid var(--border-neutral); border-radius: 12px; padding: 14px 16px; font-size: .92rem; line-height: 1.7; color: var(--ink); }
.reveal-next { color: var(--brand); font-weight: 700; font-size: .86rem; cursor: pointer; padding: 6px 2px; display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; }
.reveal-next:hover { color: var(--brand-d); }
.q-card { margin-bottom: 12px; }
.q-card .q-label { font-size: .88rem; font-weight: 700; color: var(--mute); margin-bottom: 8px; word-break: keep-all; }
.q-card .textarea { min-height: 5rem; }

/* ===== 로딩 ===== */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; min-height: 100%; }
.loading-screen .spinner { width: 40px; height: 40px; border: 3px solid var(--border-neutral); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-screen p { color: var(--soft); font-weight: 500; animation: pulse 1.5s infinite; }

/* ===== 최종 리포트 (총평) ===== */
.report-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.report-nav .icon-btn { color: var(--soft); background: none; border: none; padding: .25rem; transition: color .15s; }
.report-nav .icon-btn:hover { color: var(--ink); }
.report-nav .reset-btn { font-size: .8rem; font-weight: 700; color: var(--soft); background: #fff; border: 1px solid var(--border-neutral); padding: .5rem 1rem; border-radius: 50px; transition: all .15s; }
.report-nav .reset-btn:hover { color: var(--ink); border-color: var(--brand-l); }
.report-card { position: relative; overflow: hidden; }
.report-card .header { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-neutral); }
.report-card .header img { width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--brand-tint); object-fit: cover; }
.report-card .header .label { font-size: .7rem; font-weight: 700; color: var(--soft); letter-spacing: .04em; }
.report-card .header .title { font-size: 1.05rem; font-weight: 800; color: var(--ink); }
.report-body { font-size: .92rem; line-height: 1.85; color: var(--mute); white-space: pre-wrap; }
.report-body h3 { font-size: 1.08rem; color: var(--brand-d); margin: 1rem 0 .4rem; }
.report-body strong { color: var(--ink); font-weight: 700; }
.report-qa { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.qa-card { flex: 1; min-width: 160px; border: 1px solid var(--border-neutral); border-radius: 12px; padding: 12px 14px; background: var(--bg-page); }
.qa-card .qa-q { font-size: .72rem; font-weight: 700; color: var(--brand); margin-bottom: 5px; }
.qa-card .qa-a { font-size: .85rem; color: var(--mute); line-height: 1.55; }
.download-btn { display: flex; margin: 1.4rem auto 0; max-width: 22rem; width: 100%; }
.report-quote { text-align: center; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-neutral); font-style: italic; font-size: .85rem; color: var(--soft); }

/* ===== 토스트 ===== */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 12px 20px; border-radius: 50px; font-size: .85rem; font-weight: 600;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: all .3s; z-index: 999; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* icons */
.icon { display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }

/* ===== 유저 프로필 바 & 로그아웃 ===== */
.user-profile-bar {
  max-width: 900px; margin: 0 auto 18px; background: var(--bg-surface-white);
  border: 1px solid var(--border-neutral); border-radius: 14px; padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow-sm); flex-wrap: wrap;
}
.user-info { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--ink); }
.user-icon { font-size: 1rem; }
.user-actions { display: flex; align-items: center; gap: 8px; }
.profile-action-btn {
  font-size: .78rem; font-weight: 700; color: var(--brand-d);
  background: var(--brand-tint); border: 1.5px solid rgba(0, 82, 204, 0.2);
  border-radius: 50px; padding: 5px 12px; cursor: pointer; transition: all .15s ease;
}
.profile-action-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.profile-action-btn.logout-style { color: var(--soft); background: #f5f5f5; border-color: var(--border-neutral); }
.profile-action-btn.logout-style:hover { background: var(--red); color: #fff; border-color: var(--red); }
.app-logout-link {
  background: rgba(0, 0, 0, 0.04); border: 1px solid var(--border-neutral);
  color: var(--soft); font-size: 0.8rem; font-weight: 600; padding: 4px 10px;
  border-radius: 20px; cursor: pointer; transition: all .15s;
}
.app-logout-link:hover { background: #fbeeee; color: var(--red); border-color: rgba(184, 48, 48, 0.3); }

/* ===== 반응형 ===== */
@media (max-width: 600px) {
  .mandalart-cell { font-size: 9px; }
  .mandalart-cell.cell-hub { font-size: 8.5px; }
  .mandalart-cell.cell-core { font-size: 9.5px; }
  .landing-grid { grid-template-columns: 1fr 1fr; }
  .user-profile-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ── 세션 완료 후 점수 상승 배너 (AI 정성평가 결과) ── */
.score-gain { margin-bottom: 14px; padding: 14px 16px; border-radius: 14px; background: linear-gradient(135deg, #eef3fb, #e3edfb); border: 1px solid #cfe0f7; display: flex; flex-direction: column; gap: 8px; animation: slideUp .4s ease; }
.score-gain.loading { flex-direction: row; align-items: center; gap: 10px; color: var(--brand-d); font-size: .86rem; font-weight: 600; }
.score-gain .sg-label { font-size: .84rem; font-weight: 700; color: var(--brand-d); }
.score-gain .sg-label b { color: var(--brand); }
.score-gain .sg-track { display: flex; align-items: center; gap: 10px; }
.score-gain .sg-from { font-size: 1.1rem; font-weight: 700; color: var(--soft); }
.score-gain .sg-arrow { color: var(--brand-l); font-weight: 800; }
.score-gain .sg-to { font-size: 1.6rem; font-weight: 800; color: var(--brand); line-height: 1; }
.score-gain .sg-to small { font-size: .8rem; font-weight: 700; margin-left: 1px; }
.score-gain .sg-delta { margin-left: auto; font-size: .82rem; font-weight: 800; color: #fff; background: var(--green); padding: 4px 10px; border-radius: 50px; }
.spinner.sm { width: 16px; height: 16px; border: 2px solid var(--border-neutral); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; box-sizing: border-box; }
