/* [교사 수업 후 설문 2026-11-12] js/teacher-survey-modal.js 의 창 · 녹음 줄
   설계 §6-3 · 목업(Downloads ALC_만족도조사_교사설문_설계_20261112.html 4번 교사 창 · 녹음 줄 · 음량 막대)을 토큰으로 옮겼다.
   ★창은 고정 크기★ 640×660 · 좁은 화면(680 이하)은 «화면 폭 · 화면 높이 - 32» 한 값 · 넘치는 문항은 본문 안에서 스크롤.
   ★녹음 줄은 어느 상태든 50px★ 단추·막대가 바뀌어도 줄 높이와 단추 자리가 그대로다.
   ★음량 막대에 transition·animation 을 걸지 않는다★(2026-09-23 목소리 등록 창 버벅임 개선) 막대는 MicLevelMeter 가 transform 만 바꾼다. */

.tsv-overlay {   /* 공용 확인창(ui-confirm · 10060)보다 한 층 아래 — 다른 기능의 확인창이 떠도 그 아래에 깔린다 */
  position: fixed; inset: 0; z-index: 10050;
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4); background: rgba(15, 23, 42, .55);
}
.tsv-box {
  box-sizing: border-box; width: 640px; height: 660px;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);   /* dvh 를 모르는 옛 브라우저는 앞 줄 */
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--text); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  word-break: keep-all; line-height: 1.5;
}
/* 설문 메뉴 탭 — 창이 아니라 페이지 안에 그린다 · 탭 줄과 같은 왼쪽 기준선 · 묶음마다 카드(결과 탭 카드와 같은 모양) */
.tsv-inline .tsv-box { width: 100%; max-width: 880px; height: auto; max-height: none; margin: 0; overflow: visible;
  background: none; border-radius: 0; box-shadow: none; }
.tsv-top { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-4); }
.tsv-top .tsv-btn { height: 36px; padding: 0 14px; }
.tsv-inline .tsv-head { padding: 0; border: 0; font-size: var(--text-lg); font-weight: 800; }
.tsv-date { color: var(--text-muted); }
.tsv-inline .tsv-body { display: grid; gap: var(--space-3); padding: 0; overflow: visible; }
.tsv-inline .tsv-sect { margin: 0; padding: var(--space-4); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-xs); }
.tsv-inline .tsv-foot { padding: var(--space-4) 0 0; border: 0; background: none; }
.tsv-inline .tsv-submit { min-width: 120px; height: 44px; }
@media (max-width: 680px) { .tsv-inline .tsv-submit { flex: 1 1 auto; } .tsv-inline .tsv-msg { flex-basis: 100%; } .tsv-inline .tsv-foot { flex-wrap: wrap; } }
.tsv-head { flex: none; margin: 0; padding: 16px 22px 12px; border-bottom: 1px solid var(--border);
  font-size: var(--text-lg); font-weight: 700; line-height: 1.4; }
.tsv-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 20px 22px; }
.tsv-foot { flex: none; display: flex; align-items: center; gap: var(--space-2); padding: 12px 18px;
  border-top: 1px solid var(--border); background: var(--surface); }
.tsv-msg { flex: 1 1 auto; min-width: 0; margin: 0; font-size: var(--text-sm); font-weight: 600; color: var(--danger); }
.tsv-btn { flex: none; height: 40px; padding: 0 16px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-body); font: inherit; font-size: var(--text-base); font-weight: 600; cursor: pointer; }
.tsv-btn:hover:not(:disabled) { background: var(--surface-hover); }
.tsv-pri { border-color: var(--primary-fill); background: var(--primary-fill); color: var(--text-on-primary); }
.tsv-pri:hover:not(:disabled) { background: var(--primary-fill-hover); }
.tsv-box button:disabled, .tsv-box select:disabled, .tsv-box [aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
/* 다른 창에서 이미 냈다 — 단추는 위의 disabled 모양 · 글 칸은 읽기 전용(글자는 그대로 읽히게 바탕만) · 안내는 실패가 아니라 본문 글자색 */
.tsv-box.is-done .tsv-txt { background: var(--surface-2); }
.tsv-box.is-done .tsv-msg { color: var(--text-body); }
.tsv-box button:focus-visible, .tsv-box select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* 묶음 · 문항 */
.tsv-sect { margin: 0 0 18px; }
.tsv-sect:last-child { margin-bottom: 0; }
.tsv-sect-t { margin: 0; font-size: var(--text-md); font-weight: 700; line-height: 1.45; }
.tsv-sect-h { margin: 2px 0 0; font-size: var(--text-sm); color: var(--text-muted); }
.tsv-q { margin-top: var(--space-3); }
.tsv-q-l { margin: 0 0 6px; font-size: var(--text-base); font-weight: 600; }
.tsv-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.tsv-opt { height: 36px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface); color: var(--text-body); font: inherit; font-size: var(--text-base); cursor: pointer; }
.tsv-opt[aria-checked="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }

/* 답 칸 = 글 칸(2줄) + 녹음 줄(아래 한 줄 전체) */
.tsv-ans { margin-top: var(--space-2); }
.tsv-ans[hidden] { display: none; }
.tsv-txt { display: block; box-sizing: border-box; width: 100%; height: 60px; margin: 0; padding: 8px 10px; resize: none;
  border: 1px solid var(--border-input); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--text-base); line-height: 1.45; }
.tsv-txt::placeholder { color: var(--text-muted); }
.tsv-txt:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }

.tsv-recrow { box-sizing: border-box; display: flex; align-items: center; gap: 10px; height: 50px; margin-top: 6px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-subtle); overflow: hidden; }
.tsv-recrow[data-state="recording"] { border-color: color-mix(in srgb, var(--danger) 35%, var(--surface)); background: var(--danger-light); }
/* 줄의 칸 순서: 단추(ctl) · 소리 없음(warn · 알림 영역) · 알림 아닌 글(note) · 시간 · 뒤 단추(tail) */
.tsv-ctl, .tsv-tail { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.tsv-tail { order: 5; margin-left: auto; }
.tsv-recrow.is-rec .tsv-ctl { flex: 1 1 auto; }          /* 녹음 뒤: 재생 막대가 남는 폭을 쓴다 */
.tsv-warn, .tsv-note { flex: 1 1 auto; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  font-size: var(--text-sm); font-weight: 700; line-height: 1.3; }
.tsv-warn { order: 1; color: var(--warning-dark); }
.tsv-note { order: 2; color: var(--danger); }            /* 쉴 때 = 마이크를 못 연 까닭 */
.tsv-note:empty, .tsv-tail:empty { display: none; }   /* 빈 뒤 단추 칸이 시간을 가운데로 끌지 않게 */
.tsv-warn:empty { flex: 0 0 0; }   /* ★알림 영역은 비어도 그려 둔다★ display:none 이면 글이 들어오는 순간의 알림이 안 읽힌다 */
.tsv-recrow.is-rec .tsv-note { order: 4; flex: 0 0 auto; color: var(--text-body); }   /* «올리는 중»은 시간 오른쪽 */
.tsv-time { order: 3; flex: 0 0 auto; margin-left: auto; font-size: var(--text-sm); color: var(--text-body); white-space: nowrap;
  font-variant-numeric: tabular-nums; }
.tsv-recrow.is-rec .tsv-tail { margin-left: 0; }
/* 녹음 뒤 «다시 녹음»에서 마이크를 못 열었다 — 재생 막대·시간 자리에 그 까닭을 보인다(앞 녹음은 남는다) */
.tsv-recrow.is-rec.has-err .tsv-ctl { flex: 0 0 auto; }
.tsv-recrow.is-rec.has-err .tsv-pbar, .tsv-recrow.is-rec.has-err .tsv-time { display: none; }
.tsv-recrow.is-rec.has-err .tsv-note { order: 2; flex: 1 1 auto; color: var(--danger); }
.tsv-recrow[data-state="idle"] .tsv-time { display: none; }

.tsv-rbtn { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-sizing: border-box;
  height: 34px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-sm); font-weight: 700; white-space: nowrap; cursor: pointer; }
.tsv-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.tsv-sq { width: 10px; height: 10px; background: currentColor; }
.tsv-rec.is-stop { border-color: var(--danger-fill); background: var(--danger-fill); color: var(--text-on-primary); }
.tsv-play { border-color: var(--primary-fill); background: var(--primary-fill); color: var(--text-on-primary); }

.tsv-meter { flex: none; display: flex; align-items: flex-end; gap: 3px; height: 24px; }
.tsv-meter i { display: block; width: 5px; height: 100%; border-radius: 1px; background: var(--border-strong);   /* [design-ok] 5px 막대 끝 둥글기 — 4px 는 막대 폭과 비슷해 알약이 된다 */
  transform-origin: bottom; transform: scaleY(.1); will-change: transform; }
.tsv-meter i.is-loud { background: var(--success); }
.tsv-pbar { flex: 1 1 auto; min-width: 40px; height: 6px; position: relative; overflow: hidden; border-radius: 999px; background: var(--border); }
.tsv-pbar b { position: absolute; inset: 0; background: var(--primary); transform-origin: left; transform: scaleX(0); }

.tsv-mic { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--text-sm); color: var(--text-body); white-space: nowrap; }
.tsv-mic select { min-width: 0; max-width: 200px; height: 30px; padding: 0 6px; border: 1px solid var(--border-input);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-sm); }

@media (max-width: 680px) {
  .tsv-box { width: 100%; height: calc(100vh - 32px); height: calc(100dvh - 32px); }
  .tsv-head { padding: 14px 16px 10px; }
  .tsv-body { padding: var(--space-4); }
  .tsv-foot { padding: 10px var(--space-4); }
}
/* 아주 좁은 화면: 듣기 · 다시 녹음 · 지우기는 그림만(이름은 화면 읽기 프로그램이 그대로 읽는다) */
@media (max-width: 480px) {
  .tsv-recrow, .tsv-ctl, .tsv-tail { gap: 6px; }
  .tsv-recrow { padding: 0 8px; }
  .tsv-pbar { min-width: 0; }
  .tsv-play, .tsv-tail .tsv-rbtn { width: 36px; padding: 0; }
  .tsv-play .tsv-lbl, .tsv-tail .tsv-lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tsv-recrow[data-state="recording"] .tsv-t2 { display: none; }
  .tsv-recrow.is-quiet .tsv-meter { display: none; }   /* 소리 없음 문구가 막대 자리를 쓴다 */
}
@media (pointer: coarse) {   /* 손가락 기기 누름 44px(R152) — 녹음 줄 안쪽 48px 에 들어간다 */
  .tsv-btn, .tsv-opt, .tsv-rbtn, .tsv-mic select { min-height: 44px; }
  .tsv-play, .tsv-tail .tsv-rbtn { min-width: 44px; }
}
