/* 교사 전용 생기부 도우미. 화면 오른쪽 가장자리의 책갈피 탭을 당기면 기재요령 옆에 펼쳐 두는 서랍이 열립니다.
   색은 앱의 종이(카드)·남색 잉크·노란 형광펜 토큰만 씁니다. */
.rc-launch {
  position: fixed; right: 0; bottom: calc(148px + env(safe-area-inset-bottom, 0px)); z-index: 13;
  display: flex; flex-direction: column; align-items: center; gap: 9px; width: 44px; padding: 14px 0 15px 4px; box-sizing: border-box;
  color: var(--ms-card, #fffdf8); background: var(--ms-ink, #2c3566); border: 0; border-radius: 14px 0 0 14px;
  box-shadow: inset 4px 0 0 var(--sb-yellow, #f6c24a), -4px 8px 20px rgb(44 53 102 / 22%);
  font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: width .18s ease, box-shadow .18s ease;
}
.rc-launch[hidden], .rc-dialog [hidden], .rc-dialog[hidden] { display: none !important; }
.rc-launch-icon { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rc-launch-ribbon, .rc-mark-ribbon { fill: var(--sb-yellow, #f6c24a); stroke: var(--sb-yellow, #f6c24a); }
.rc-launch-label { writing-mode: vertical-rl; text-orientation: upright; font-size: 14px; font-weight: 700; line-height: 1; letter-spacing: .16em; }
.rc-launch-tip { position: absolute; right: calc(100% + 10px); top: 50%; translate: 0 -50%; padding: 7px 11px; color: var(--ms-card, #fffdf8); background: var(--ms-ink, #2c3566); border-radius: 9px; font-size: 12px; font-weight: 600; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
@media (hover: hover) {
  .rc-launch:hover { width: 50px; box-shadow: inset 4px 0 0 var(--sb-yellow, #f6c24a), -6px 10px 24px rgb(44 53 102 / 28%); }
  .rc-launch:is(:hover, :focus-visible) .rc-launch-tip { opacity: 1; }
}
body:has(#growthView:not(.hidden) .gb-fab) .rc-launch { bottom: calc(172px + env(safe-area-inset-bottom, 0px)); }
/* 다른 창의 배경에서는 탭을 숨겨 두 모달의 포커스가 겹치지 않게 합니다. */
body:is(.rc-modal-open, .phone-sheet-open, .manual-open, .install-open, .notice-open, .tp-open) .rc-launch,
body:has(.modal:not(.hidden):not([hidden]), .sp-side.is-overlay, #growthView:not(.hidden) .gb-sheet-layer) .rc-launch { visibility: hidden; pointer-events: none; }
body.rc-modal-open { overflow: hidden; }

.rc-dialog {
  --rc-ink: var(--ms-ink, #2c3566); --rc-text: var(--ms-text, #3a3f62); --rc-muted: var(--ms-muted, #5f6480);
  --rc-line: var(--ms-line, #e8e0cd); --rc-hair: var(--ms-hair, #f1ebdc); --rc-paper: var(--ms-card, #fffdf8); --rc-desk: var(--ms-soft, #f7f3e9);
  --rc-mark: var(--sb-yellow, #f6c24a); --rc-mark-soft: var(--ms-amber-soft, #fdf3d7); --rc-amber: var(--ms-amber, #8a5a10);
  --rc-ok: var(--ms-green, #1f7040); --rc-error: var(--ms-coral, #b93825); --rc-error-soft: var(--ms-coral-soft, #fdebe5);
  position: fixed; inset: 0; z-index: 60; display: flex; justify-content: flex-end; background: rgb(28 30 52 / 28%); color: var(--rc-text); font-family: inherit;
}
.rc-panel {
  position: relative; width: min(500px, 100vw); height: 100%; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--rc-paper); box-shadow: -20px 0 50px rgb(44 53 102 / 18%);
  animation: rc-drawer .2s ease-out;
}
/* 탭과 같은 노란 책갈피 띠가 서랍 가장자리를 따라 이어집니다. */
.rc-panel::before { content: ''; position: absolute; inset: 0 auto 0 0; z-index: 2; width: 4px; background: var(--rc-mark); pointer-events: none; }
@keyframes rc-drawer { from { transform: translateX(28px); opacity: 0; } }
.rc-dialog button, .rc-dialog textarea, .rc-dialog select { font: inherit; }
.rc-dialog button { cursor: pointer; }
.rc-dialog button:disabled { cursor: not-allowed; }
#studentRecordChat :is(button, select, textarea, a, summary):focus-visible, #openStudentRecordChatBtn:focus-visible { outline: 2px solid var(--ms-ink, #2c3566); outline-offset: 3px; }

/* 머리: 탭과 같은 책 표시, 제목, 새 대화·닫기 */
.rc-head { flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 16px 16px 15px 24px; border-bottom: 1px solid var(--rc-line); }
.rc-mark { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; color: var(--rc-paper); background: var(--rc-ink); }
.rc-mark svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.rc-titles { min-width: 0; flex: 1; }
.rc-titles h2 { margin: 0; color: var(--rc-ink); font-size: 17px; line-height: 1.35; font-weight: 700; letter-spacing: -.03em; }
.rc-titles p { margin: 2px 0 0; color: var(--rc-muted); font-size: 12px; line-height: 1.45; }
.rc-head-actions { display: flex; align-items: center; gap: 4px; }
.rc-head-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 36px; padding: 0 12px 0 10px; border: 1px solid var(--rc-line); border-radius: 10px; color: var(--rc-ink); background: var(--rc-paper); font-size: 13px; font-weight: 600; white-space: nowrap; }
.rc-head-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.rc-head-btn--icon { width: 36px; padding: 0; border-color: transparent; }
.rc-head-btn--icon svg { width: 18px; height: 18px; }
.rc-head-btn:hover { background: var(--rc-desk); }

/* 대화 */
.rc-conversation { min-height: 0; flex: 1; padding: 22px 22px 10px 26px; overflow-y: auto; overscroll-behavior: contain; scroll-padding-top: 14px; }
.rc-welcome { padding: 6px 0 18px; }
.rc-welcome h3 { margin: 0 0 6px; color: var(--rc-ink); font-size: 20px; line-height: 1.4; font-weight: 700; letter-spacing: -.035em; }
.rc-welcome p { margin: 0; max-width: 34em; color: var(--rc-muted); font-size: 14px; line-height: 1.7; }
.rc-examples { display: grid; gap: 8px; margin-top: 20px; }
.rc-examples button, .rc-related button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; border: 1px solid var(--rc-line); border-radius: 12px;
  color: var(--rc-ink); background: var(--rc-desk); font-size: 14px; font-weight: 500; line-height: 1.5; text-align: left;
}
.rc-examples button::before { content: ''; flex: none; width: 4px; align-self: stretch; border-radius: 2px; background: var(--rc-line); }
.rc-examples button:not(:disabled):hover, .rc-related button:not(:disabled):hover { border-color: #d9cfb6; background: var(--rc-mark-soft); }
.rc-examples button:not(:disabled):hover::before { background: var(--rc-mark); }
.rc-examples button:disabled, .rc-related button:disabled { opacity: .55; }
.rc-turn { margin-bottom: 28px; }
.rc-user { width: fit-content; max-width: 86%; margin: 0 0 14px auto; padding: 10px 14px; border-radius: 16px 16px 4px 16px; color: var(--rc-paper); background: var(--rc-ink); font-size: calc(14px * var(--reading-scale, 1)); line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.rc-answer-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--rc-ok); font-size: 12.5px; font-weight: 700; line-height: 1.4; }
.rc-answer-head::before { content: ''; flex: none; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 16%, transparent); }
.rc-answer-head[data-status="clarify"], .rc-answer-head[data-status="insufficient"] { color: var(--rc-amber); }
.rc-answer-head[data-status="blocked"] { color: var(--rc-error); }
.rc-answer { color: var(--rc-text); font-size: calc(15px * var(--reading-scale, 1)); line-height: 1.8; overflow-wrap: anywhere; word-break: keep-all; }
.rc-answer p { margin: 0; white-space: pre-wrap; }
.rc-answer p + p { margin-top: 10px; }
.rc-cite {
  display: inline-flex; align-items: center; justify-content: center; min-width: 19px; height: 19px; margin: 0 1px; padding: 0 5px; box-sizing: border-box;
  border-radius: 10px; color: var(--rc-ink); background: var(--rc-mark-soft); box-shadow: inset 0 0 0 1px #ecd9a4; font-size: 11px; font-weight: 700; line-height: 1;
  text-decoration: none; vertical-align: 2px; font-variant-numeric: tabular-nums;
}
.rc-cite:hover { background: var(--rc-mark); box-shadow: none; }
/* 근거를 찾는 동안: 제영이가 책장을 넘겨 봅니다. 그림은 10장을 한 줄로 이은 /storybook/read-sprite-jeyoung.webp
   (한 장 174×216 = 화면 58×72의 3배)입니다. 1.3초에 한 장씩, 펼친 쪽을 보고(0번) 책장을 집어 넘긴 뒤(1~6번) 손을 거둡니다(7~9번).
   질문 예시처럼 답이 바로 오면 그림이 번쩍이지 않도록 0.25초 뒤에 나타납니다. */
.rc-pending { display: flex; align-items: center; gap: 12px; margin: 2px 0 0; color: var(--rc-muted); font-size: 13px; line-height: 1.5; animation: rc-pending-in .18s ease-out .25s both; }
@keyframes rc-pending-in { from { opacity: 0; } }
.rc-pending-reader { flex: none; width: 58px; height: 72px; background: url("/storybook/read-sprite-jeyoung.webp") 0 0 / 1000% 100% no-repeat; animation: rc-read 1.3s steps(1, end) infinite; }
@keyframes rc-read {
  0% { background-position: 0 0; } 27.692% { background-position: calc(100% / 9) 0; } 35.385% { background-position: calc(100% / 9 * 2) 0; }
  43.077% { background-position: calc(100% / 9 * 3) 0; } 49.231% { background-position: calc(100% / 9 * 4) 0; } 55.385% { background-position: calc(100% / 9 * 5) 0; }
  61.538% { background-position: calc(100% / 9 * 6) 0; } 68.462% { background-position: calc(100% / 9 * 7) 0; } 76.923% { background-position: calc(100% / 9 * 8) 0; }
  86.154% { background-position: 100% 0; } 100% { background-position: 0 0; }
}
.rc-pending-copy { display: grid; min-width: 0; word-break: keep-all; }
.rc-pending time { display: block; height: 18px; color: var(--rc-muted); font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; opacity: .8; }
.rc-error-note { margin: 2px 0 0; padding: 10px 12px; border-radius: 10px; color: var(--rc-error); background: var(--rc-error-soft); font-size: 13px; line-height: 1.6; }
.rc-portal-note { margin: 12px 0 0; color: var(--rc-amber); font-size: 12.5px; line-height: 1.6; }

/* 근거 자료: 번호는 답변 속 번호와 같습니다. */
.rc-sources-wrap { margin-top: 18px; }
.rc-sources-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 8px; color: var(--rc-muted); font-size: 12px; font-weight: 700; }
.rc-sources-head span { font-weight: 500; }
.rc-sources { display: grid; gap: 8px; }
.rc-source { display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: 10px; padding: 11px 13px 11px 11px; border: 1px solid var(--rc-line); border-radius: 12px; background: var(--rc-desk); scroll-margin: 12px; transition: background-color .5s ease, border-color .5s ease; }
.rc-source > :not(.rc-source-num) { grid-column: 2; }
.rc-source-num { grid-row: 1 / span 6; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: var(--rc-ink); background: var(--rc-paper); box-shadow: inset 0 0 0 1px var(--rc-line); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rc-source.is-flash { border-color: #e7c76a; background: var(--rc-mark-soft); }
.rc-source-kind { display: block; margin: 2px 0 3px; color: var(--rc-amber); font-size: 12px; font-weight: 700; line-height: 1.4; }
.rc-source a { color: var(--rc-ink); font-size: 13.5px; font-weight: 600; line-height: 1.5; text-decoration: none; overflow-wrap: anywhere; }
.rc-source a:hover { text-decoration: underline; text-underline-offset: 3px; }
.rc-source-out { display: inline-block; width: 12px; height: 12px; margin-left: 4px; vertical-align: -1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .7; }
.rc-source-meta { margin: 3px 0 0; color: var(--rc-muted); font-size: 11.5px; line-height: 1.5; }
.rc-source-access { margin: 3px 0 0; color: var(--rc-amber); font-size: 11.5px; line-height: 1.5; }
.rc-source details { margin-top: 6px; color: var(--rc-text); font-size: 12.5px; line-height: 1.7; }
.rc-source summary { width: fit-content; color: var(--rc-muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.rc-source summary:hover { color: var(--rc-ink); }
.rc-source blockquote { max-height: 220px; overflow: auto; margin: 8px 0 2px; padding: 9px 11px; border-left: 3px solid var(--rc-mark); border-radius: 0 8px 8px 0; background: var(--rc-paper); white-space: pre-wrap; overflow-wrap: anywhere; }
.rc-related { display: grid; gap: 6px; margin-top: 12px; }

/* 입력 */
.rc-form { flex-shrink: 0; margin: 0; padding: 12px 16px max(14px, env(safe-area-inset-bottom)) 20px; border-top: 1px solid var(--rc-line); background: var(--rc-paper); }
.rc-status-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 2px 10px; }
.rc-status-row:has(.rc-status:empty):has(.rc-retry[hidden]) { display: none; }
.rc-status-row:has(.rc-status[data-tone="busy"]):has(.rc-retry[hidden]) { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); }
.rc-status { margin: 0; color: var(--rc-muted); font-size: 12.5px; line-height: 1.55; }
.rc-status:empty { display: none; }
.rc-status[data-tone="error"] { color: var(--rc-error); }
.rc-retry { flex-shrink: 0; height: 30px; padding: 0 11px; border: 1px solid var(--rc-line); border-radius: 8px; color: var(--rc-ink); background: var(--rc-paper); font-size: 12px !important; font-weight: 600 !important; }
.rc-retry:hover { background: var(--rc-desk); }
.rc-question-label, .rc-grade span { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.rc-compose { border: 1px solid var(--rc-line); border-radius: 16px; background: var(--rc-paper); box-shadow: 0 1px 0 var(--rc-hair); transition: border-color .15s ease, box-shadow .15s ease; }
.rc-compose:focus-within { border-color: var(--rc-ink); box-shadow: 0 0 0 3px rgb(44 53 102 / 10%); }
#studentRecordChat .rc-compose textarea {
  display: block; width: 100%; min-height: 54px; max-height: 168px; box-sizing: border-box; margin: 0; padding: 12px 14px 2px;
  border: 0; outline: 0; resize: none; overflow-y: auto; color: var(--rc-ink); background: transparent; box-shadow: none; font-size: 15px; line-height: 1.6;
}
#studentRecordChat .rc-compose textarea::placeholder { color: var(--rc-muted); opacity: .75; }
#studentRecordChat .rc-compose textarea:focus-visible { outline: 0; box-shadow: none; }
.rc-compose-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 8px 10px; }
.rc-grade { position: relative; display: inline-flex; margin: 0; }
#studentRecordChat .rc-grade select {
  width: auto; min-height: 30px; height: 30px; margin: 0; padding: 0 28px 0 11px; border: 1px solid var(--rc-line); border-radius: 999px;
  color: var(--rc-ink); background: var(--rc-desk) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232c3566' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") right 9px center / 13px no-repeat;
  font-size: 12.5px; font-weight: 600; line-height: 1; box-shadow: none; appearance: none; -webkit-appearance: none; cursor: pointer;
}
#studentRecordChat .rc-grade select:disabled { opacity: .5; cursor: not-allowed; }
.rc-followup { padding: 4px 9px; border-radius: 999px; color: var(--rc-amber); background: var(--rc-mark-soft); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.rc-count { margin-left: auto; color: var(--rc-muted); font-size: 11.5px; font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .15s ease; }
.rc-count[data-active="true"] { opacity: 1; }
.rc-count[data-tone="warn"] { color: var(--rc-error); }
.rc-send {
  position: relative; flex: none; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%;
  color: var(--ms-action-ink, #fffdf8); background: var(--ms-action, #2c3566); transition: background-color .15s ease, opacity .15s ease;
}
.rc-send:not(:disabled):hover { background: var(--ms-action-hover, #3a4478); }
.rc-send:disabled { opacity: .35; }
.rc-send-arrow { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.rc-send-spin { display: none; width: 16px; height: 16px; box-sizing: border-box; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rc-spin .8s linear infinite; }
.rc-send[data-state="busy"] { opacity: .8; }
.rc-send[data-state="busy"] .rc-send-arrow { display: none; }
.rc-send[data-state="busy"] .rc-send-spin { display: block; }
@keyframes rc-spin { to { transform: rotate(360deg); } }
.rc-hint { margin: 8px 4px 0; color: var(--rc-muted); font-size: 11.5px; line-height: 1.55; }

@media (max-width: 650px) {
  .rc-launch { bottom: calc(var(--ms-tabbar, 78px) + 96px + env(safe-area-inset-bottom, 0px)); width: 36px; gap: 7px; padding: 11px 0 12px 4px; border-radius: 12px 0 0 12px; }
  .rc-launch-icon { width: 18px; height: 18px; }
  .rc-launch-label { font-size: 12px; }
  body:has(#growthView:not(.hidden) .gb-fab) .rc-launch { bottom: calc(var(--ms-tabbar, 78px) + 108px + env(safe-area-inset-bottom, 0px)); }
  .rc-dialog { top: var(--rc-viewport-top, 0); bottom: auto; height: var(--rc-viewport-height, 100dvh); }
  .rc-panel { width: 100%; box-shadow: none; animation-name: rc-sheet; }
  .rc-panel::before { display: none; }
  @keyframes rc-sheet { from { transform: translateY(24px); opacity: 0; } }
  .rc-head { padding: max(12px, env(safe-area-inset-top)) 10px 12px 16px; gap: 10px; }
  .rc-mark { width: 34px; height: 34px; border-radius: 10px; }
  .rc-mark svg { width: 19px; height: 19px; }
  .rc-titles h2 { font-size: 16px; }
  .rc-titles p { font-size: 11.5px; }
  .rc-head-btn { height: 34px; padding: 0 10px 0 8px; font-size: 12.5px; }
  .rc-head-btn--icon { width: 34px; padding: 0; }
  .rc-conversation { padding: 18px 16px 8px; }
  .rc-welcome h3 { font-size: 19px; }
  .rc-user { max-width: 90%; }
  .rc-form { padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }
  #studentRecordChat .rc-compose textarea { min-height: 46px; padding-top: 11px; font-size: 16px; }
  .rc-hint { margin-top: 6px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  .rc-panel { animation: none; }
  .rc-pending-reader { animation: none; }
  .rc-send-spin { animation-duration: 2.4s; }
  .rc-launch, .rc-source, .rc-count, .rc-compose { transition: none; }
}
@media print { .rc-dialog, .rc-launch { display: none !important; } }
