/* =====================================================================
   SO君パネル — チャット内部（C の下書き。B が teacher-free.css の末尾「チャット内部」節に取り込む）
   docs/TEACHER-S3-PARENT.md §4・§7.4。元は assets/css/fullscreen-ui.css（旧 UI。index.php からはもう読まない）

   画面の配置（全画面の fixed/absolute・セクション・世界レイヤー・ハンバーガー）は持ち込まない。
   パネルの箱は teacher-free.css（B）が作る。この節が前提にしている箱:

     aside#soPanel { position: relative; display: flex; flex-direction: column; min-height: 0 }
       ├ （B のヘッダー: SO君・「SO君に相談」・#soStatusLine・#soPanelToggle）
       ├ .chat-area > #messageArea.messages-container … .chat-area が縦にスクロールする箱（大きさと overflow は
       │     teacher-free.css の #soPanel .chat-area）。app.js もこれをスクロールする（getChatScrollArea）
       ├ #quickPromptChips.quick-prompt-chips
       ├ #inputArea.input-area             … 下に固定。「📎 作品を見せる」のスイッチは入力欄の中（.tf-share）
       └ #loginRequiredCard（⑥a）／#aiProhibitedCard（⑥b）
     どこに置いてもよい: #historyPanel（画面の右端に固定でかぶさる。幅はパネルと同じ 360px）
     body 直下: #voiceModal #nicknameModal #loadingOverlay #toastContainer（position:fixed。
                パネルに transform を掛けても基準がずれないよう #soPanel の外に置く）

   色は方向 A（--tf-*。§7。:root が未定義でも読めるよう var() に既定値を付けた）。
   ユーザーの吹き出し＝青、SO君＝白＋銀の縁。keyframes は B と名前が重ならないよう tf-chat- を付けた
   ===================================================================== */

/* Safari(WebKit)のルビ描画差の補正（本体 style.css・旧 fullscreen-ui.css と同じ。ページ全体に効く）。
   WebKit はルビ(rt)を漢字から離して描画し行高も膨らむため、WebKit 限定でrtを基底側へ引き寄せる */
@supports (background: -webkit-named-image(i)) {
  rt {
    margin-bottom: -0.5em;
  }
}

/* ふりがな表示の切り替え（app.js が body に .hide-furigana を付け外しする） */
.hide-furigana ruby rt {
  display: none !important;
}

.hide-furigana ruby {
  display: inline;
}

/* ----------------------------------------
   メッセージ欄
   ---------------------------------------- */

/* 縦にスクロールするのは外側の .chat-area（teacher-free.css の #soPanel .chat-area）。
   ここはメッセージを縦に並べるだけ（overflow を付けると二重スクロールになる） */
.messages-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-area {
  scrollbar-width: thin;
  scrollbar-color: var(--tf-silver-d, #8f9cad) transparent;
}

.chat-area::-webkit-scrollbar {
  width: 8px;
}

.chat-area::-webkit-scrollbar-thumb {
  background: var(--tf-silver, #c9d3df);
  border-radius: 8px;
}

.message {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: tf-chat-message-in 0.3s ease-out;
}

.message.user {
  flex-direction: row-reverse;
}

.message .avatar {
  width: 44px;
  min-height: 40px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  overflow: visible; /* ニックネームがはみ出せるように */
}

.message .avatar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

/* SO君のアバター（背景透明、角なし） */
.message.assistant .avatar img {
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* ユーザーのアバター（押すとアイコンを変えられる） */
.message.user .avatar img {
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--tf-blue, #2f86ea);
}

/* ユーザーのニックネーム（スクモンと同じスタイル） */
.message .avatar .user-nickname {
  position: relative;
  z-index: 1;
  margin-top: -6px;
  width: max-content;
  max-width: 72px;
  line-height: 1.1;
  font-family: 'Dela Gothic One', sans-serif;
  font-size: 12px;
  text-shadow: 1px 1px 1px #fff, -1px 1px 1px #fff, 1px -1px 1px #fff, -1px -1px 1px #fff;
  text-align: center;
  color: var(--tf-ink, #22303f);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 吹き出し: SO君＝白＋銀の縁 */
.message .content {
  min-width: 0;
  max-width: calc(100% - 56px);
  padding: 10px 14px;
  background: #fff;
  color: var(--tf-ink, #22303f);
  border: 3px solid var(--tf-silver, #c9d3df);
  border-radius: 18px;
  border-top-left-radius: 6px;
  box-shadow: 0 3px 0 var(--tf-silver-d, #8f9cad);
  line-height: 1.7;
  font-size: 14px;
  overflow-wrap: anywhere;
  word-wrap: break-word;
}

/* 吹き出し: ユーザー＝青 */
.message.user .content {
  background: linear-gradient(180deg, var(--tf-blue-l, #5db2ff), var(--tf-blue, #2f86ea));
  color: #fff;
  border-color: var(--tf-blue-d, #1a63c8);
  border-top-left-radius: 18px;
  border-top-right-radius: 6px;
  box-shadow: 0 3px 0 var(--tf-navy, #123a7a);
}

.message .content a {
  color: var(--tf-blue-d, #1a63c8);
  text-decoration: underline;
}

.message.user .content a {
  color: #fff;
}

/* AI回答の通報ボタンの行（app.js が <style> を注入する。字下げだけパネルのアバター幅に合わせる） */
.messages-container .teacher-report-actions {
  padding-left: 52px;
}

/* 考え中（返事待ち）の点々 */
.typing-indicator {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: tf-chat-fade-in 0.3s;
}

.typing-indicator .avatar {
  width: 44px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.typing-indicator .avatar img {
  width: 40px;
  height: 40px;
  object-fit: cover;
}

.typing-indicator .dots-container {
  padding: 12px 16px;
  background: #fff;
  border: 3px solid var(--tf-silver, #c9d3df);
  border-radius: 18px;
  border-top-left-radius: 6px;
  box-shadow: 0 3px 0 var(--tf-silver-d, #8f9cad);
}

.dots {
  display: flex;
  justify-content: center;
  align-items: center;
}

.dot {
  width: 9px;
  height: 9px;
  margin: 0 4px;
  border-radius: 50%;
  background-color: var(--tf-blue, #2f86ea);
  opacity: 0;
  animation: tf-chat-dot 2s infinite;
}

.dot:nth-child(2) {
  animation-delay: 0.5s;
}

.dot:nth-child(3) {
  animation-delay: 1s;
}

/* 学校 verify 待ちなどのシステムのお知らせ */
.system-notice {
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  font-size: 13px;
}

.system-notice.warning {
  background-color: #fff3cd;
  border: 1px solid #ffeaa7;
  color: #856404;
}

/* 「保護者／先生も見られるよ」のお知らせ（初期挨拶の中の span。見た目は本文と同じ） */
.guardian-notice {
  color: inherit;
}

/* ----------------------------------------
   Scratch ブロック（scratchblocks の入れ物）
   ---------------------------------------- */

.scratch-code-block {
  margin: 0.6rem 0;
  padding: 0.6rem;
  background: #f5f8fc;
  border: 1px solid var(--tf-line, #dde5ee);
  border-radius: 10px;
  overflow-x: auto;
}

.scratch-code-block pre {
  margin: 0;
  white-space: pre-wrap;
}

.scratchblocks svg,
.scratchblocks-rendered svg {
  max-width: 100%;
  height: auto;
}

/* クリックで拡大できる */
.scratchblocks-rendered svg {
  cursor: zoom-in;
  transition: opacity 0.2s;
}

.scratchblocks-rendered svg:hover {
  opacity: 0.9;
}

/* Scratch3 コメントの文字色・背景 */
.scratchblocks-rendered svg .sb3-comment-label,
.scratchblocks-rendered svg .sb3-comment-label text,
.scratchblocks-rendered svg .sb3-comment text {
  fill: #000 !important;
}

.scratchblocks-rendered .sb3-comment-rect {
  fill: #ffffa5 !important;
  stroke: #d0d1d2 !important;
}

/* カスタムブロックの引数（ピンク） */
.scratchblocks-rendered svg .sb3-custom-arg {
  fill: #ff6680 !important;
  stroke: #cf4a69 !important;
}

.scratchblocks-fallback {
  padding: 0.8rem;
  background-color: #f8f8f8;
  border: 1px dashed #ddd;
  font-family: monospace;
  white-space: pre-wrap;
}

.scratchblocks-error {
  border-color: #ffcccc;
  background-color: #fff5f5;
}

.scratch-fallback-note {
  margin-top: 0.4rem;
  font-size: 12px;
  color: #666;
  font-style: italic;
}

/* 表示できなかったブロックの警告 */
.block-warning {
  display: block;
  margin: 6px 0;
  padding: 6px 10px;
  background-color: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  font-size: 12px;
  color: #856404;
}

.code-error {
  font-size: 12px;
  color: #856404;
}

/* ブロックの拡大モーダル（createSVGZoomModal） */
.svg-zoom-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
}

.svg-zoom-modal.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

.svg-zoom-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  cursor: pointer;
}

.svg-zoom-content {
  position: relative;
  z-index: 1;
  max-width: 95vw;
  max-height: 95vh;
  padding: 20px;
  padding-top: 52px;
  background: #fff;
  border: 6px solid #dfe6f2;
  border-radius: 20px;
  box-shadow: 0 0 0 3px var(--tf-silver-d, #8f9cad), 0 14px 30px rgba(0, 0, 0, 0.35);
  overflow: auto;
}

.svg-zoom-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  background: #fff;
  border: 3px solid var(--tf-silver, #c9d3df);
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  color: var(--tf-ink, #22303f);
  cursor: pointer;
}

.svg-zoom-close:hover {
  background: #eef4fb;
}

.svg-zoom-container {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  min-width: 200px;
  min-height: 100px;
  max-height: 80vh;
  overflow: auto;
}

.svg-zoom-container svg {
  display: block;
  width: auto;
  height: auto;
  flex-shrink: 0;
}

.svg-zoom-container svg .sb3-comment-label,
.svg-zoom-container svg .sb3-comment-label text,
.svg-zoom-container svg .sb3-comment text {
  fill: #000 !important;
}

.svg-zoom-container svg .sb3-comment-rect {
  fill: #ffffa5 !important;
  stroke: #d0d1d2 !important;
}

/* ----------------------------------------
   会話例（未ログインのとき app.js が #messageArea に差し込む）と「作品を見せた」札
   ---------------------------------------- */

#exampleConversation {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.example-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 4px 2px;
}

.example-divider-line {
  flex: 1;
  border-top: 2px dashed var(--tf-silver, #c9d3df);
}

.example-divider-text {
  display: inline-block;
  padding: 4px 12px;
  background: #fff;
  color: var(--tf-navy, #123a7a);
  border: 2px solid var(--tf-silver, #c9d3df);
  border-radius: 999px;
  font-size: 12px;
  font-weight: bold;
  white-space: nowrap;
}

.message.example .user-nickname {
  color: #a0744e;
  font-style: italic;
}

/* 「作品を見せた」札（会話例の 3 往復目と、作品を添えて送ったユーザーの吹き出しの先頭） */
.shared-project-chip {
  display: flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  padding: 3px 10px 3px 3px;
  background: #fff8f0;
  border: 1.5px solid #ff8c42;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
  color: #d35400;
}

.shared-project-chip-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffe9d6;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1;
}

.shared-project-chip-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----------------------------------------
   クイックチップ（旧 UI の absolute 配置はやめ、普通の流れに置く）
   ---------------------------------------- */

.quick-prompt-chips {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px 8px;
}

.prompt-chip {
  display: inline-block;
  padding: 6px 12px;
  background: #fff;
  color: var(--tf-blue-d, #1a63c8);
  border: 2px solid var(--tf-blue, #2f86ea);
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--tf-blue-d, #1a63c8);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.prompt-chip:hover {
  background: #eef6ff;
  transform: translateY(-1px);
}

.prompt-chip:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 var(--tf-blue-d, #1a63c8);
}

.prompt-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 作品を添えるチップ（data-share="1"）は黄色の札 */
.prompt-chip[data-share="1"] {
  background: linear-gradient(180deg, #fff08a, var(--tf-yellow, #ffcf1f) 60%, #f5b800);
  color: var(--tf-navy, #123a7a);
  border-color: #e0a800;
  box-shadow: 0 2px 0 #b98a00;
}

.prompt-chip[data-share="1"]::before {
  content: '📎';
  margin-right: 3px;
}

/* ----------------------------------------
   入力欄（下に固定）
   ---------------------------------------- */

.input-area {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 12px;
  background: #fff;
  border-top: 2px solid var(--tf-line, #dde5ee);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: flex-end; /* 上方向に伸びる入力欄に合わせて下端でそろえる */
  gap: 4px;
  padding: 4px 4px 4px 12px;
  background: #fff;
  border: 3px solid var(--tf-silver, #c9d3df);
  border-radius: 14px;
  transition: border-color 0.15s ease;
}

.input-wrapper:focus-within {
  border-color: var(--tf-blue, #2f86ea);
}

.message-input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 164px; /* app.js adjustTextareaHeight と同じ上限 */
  padding: 7px 0;
  background: transparent;
  color: var(--tf-ink, #22303f);
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
}

.message-input::placeholder {
  color: rgba(34, 48, 63, 0.5);
}

.mic-button,
.send-button {
  flex: none;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

/* 押せる面は 44px 以上（画像はその中に置く） */
.mic-button {
  width: 44px;
  height: 44px;
}

.mic-button img {
  width: 32px;
  height: auto;
  display: block;
}

.send-button {
  min-width: 64px;
  min-height: 44px;
}

.send-button img {
  width: 64px;
  height: auto;
  display: block;
}

.mic-button:hover:not(.disabled),
.send-button:hover:not(:disabled) {
  transform: scale(1.06);
  filter: brightness(1.08);
}

/* 返事を待つ間（setUIEnabled(false)） */
.input-wrapper.disabled {
  background: #e8edf3;
}

.send-button:disabled,
.send-button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.mic-button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.message-input:disabled {
  cursor: not-allowed;
}

.message-input:disabled::placeholder {
  color: rgba(34, 48, 63, 0.35);
}

/* 音声処理中のスピナー（#voiceSpinner） */
.voice-spinner {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 1001;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  padding: 30px 40px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.voice-spinner p {
  margin: 0;
  font-size: 16px;
  font-weight: bold;
  color: var(--tf-ink, #22303f);
}

.loader {
  display: inline-block;
  width: 50px;
  height: 50px;
  border: 5px solid rgba(47, 134, 234, 0.2);
  border-top-color: var(--tf-blue, #2f86ea);
  border-radius: 50%;
  animation: tf-chat-spin 1s linear infinite;
}

/* ----------------------------------------
   ⑥a 登録のお願い（#loginRequiredCard）／⑥b お休み（#aiProhibitedCard が使ってよい）
   中の文は <div>・<p> で包む（ルビを flex の直下に置かない）
   ---------------------------------------- */

.login-required-card,
.ai-prohibited-card {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin: 10px 12px 12px;
  padding: 16px 14px 14px;
  background: #fff;
  border: 4px solid #dfe6f2;
  border-radius: 18px;
  box-shadow: 0 0 0 2px var(--tf-silver-d, #8f9cad), 0 6px 14px rgba(0, 0, 0, 0.12);
  text-align: center;
  color: var(--tf-ink, #22303f);
}

.login-required-icon {
  align-self: center;
  width: auto;
  height: 40px;
  object-fit: contain;
}

.login-required-title,
.ai-prohibited-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.7;
}

.login-required-text,
.ai-prohibited-text {
  font-size: 12px;
  line-height: 1.7;
  color: #56657a;
}

/* 主要ボタン（黄）「無料で登録する」 */
.login-required-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  background: linear-gradient(180deg, #fff08a, var(--tf-yellow, #ffcf1f) 60%, #f5b800);
  color: var(--tf-navy, #123a7a);
  border: none;
  border-radius: 999px;
  box-shadow: 0 3px 0 #b98a00;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.login-required-btn:hover {
  transform: translateY(-1px);
}

.login-required-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #b98a00;
}

/* 「もう会員の人はログイン」（login.js が .btn-header-login で拾う） */
.login-required-card .btn-header-login {
  display: block;
  width: 100%;
  padding: 8px 16px;
  background: #fff;
  color: var(--tf-blue-d, #1a63c8);
  border: 2px solid var(--tf-blue, #2f86ea);
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--tf-blue-d, #1a63c8);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.login-required-card .btn-header-login:hover {
  background: #eef6ff;
}

/* ----------------------------------------
   履歴パネル（画面の右端＝SO君パネルの場所にかぶさる。DOM の置き場所に左右されないよう fixed）
   ---------------------------------------- */

.history-panel,
.history-panel.slide-in {
  animation: tf-chat-history-in 0.25s ease-out;
}

.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: 100vw;
  z-index: 1200;
  box-shadow: -6px 0 18px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #eaf4ff, #fff 40%);
}

.history-panel .panel-header {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px 12px 14px;
  background: linear-gradient(180deg, #5db2ff, #2f86ea 50%, #1e63c6);
  box-shadow: inset 0 -4px 0 var(--tf-silver, #c9d3df), inset 0 -5px 0 var(--tf-silver-d, #8f9cad);
}

/* 見出しは白抜き太字（紺の縁取り） */
.history-panel .panel-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
  color: #fff;
  paint-order: stroke fill;
  -webkit-text-stroke: 3px var(--tf-navy, #123a7a);
  text-shadow: 0 2px 0 var(--tf-navy, #123a7a);
}

.history-panel .panel-header h3 rt {
  -webkit-text-stroke-width: 1.5px;
}

.btn-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #fff;
  color: var(--tf-navy, #123a7a);
  border: 3px solid var(--tf-silver, #c9d3df);
  border-radius: 50%;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}

.btn-close:hover {
  background: #eef4fb;
}

.history-list-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}

.history-item {
  position: relative;
  margin: 0 0 10px;
  padding: 10px 12px;
  background: #fff;
  border: 3px solid #dfe6f2;
  border-radius: 14px;
  box-shadow: 0 3px 0 var(--tf-silver-d, #8f9cad);
  cursor: pointer;
  transition: transform 0.15s ease;
  animation: tf-chat-message-in 0.3s ease-out both;
}

.history-item:hover {
  transform: translateY(-2px);
  border-color: var(--tf-blue-l, #5db2ff);
}

.history-item-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2rem;
}

.history-item-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--tf-ink, #22303f);
}

.history-item-title::before {
  content: '💬';
  flex-shrink: 0;
  font-size: 1rem;
}

.history-item-preview {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-left: 1.5rem;
  font-size: 12px;
  line-height: 1.5;
  color: #56657a;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 1.5rem;
  font-size: 11px;
  color: #8a97a8;
}

.history-item-time::before {
  content: '🕐';
  margin-right: 3px;
}

.delete-btn {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #fff;
  color: #c0392b;
  border: 2px solid #f1b8b1;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.history-item:hover .delete-btn,
.delete-btn:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .delete-btn {
    opacity: 1;
  }
}

.history-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--tf-ink, #22303f);
}

.history-empty-icon {
  margin-bottom: 0.8rem;
  font-size: 3rem;
}

.history-empty-title {
  margin-bottom: 0.4rem;
  font-size: 15px;
  font-weight: 700;
}

.history-empty-text {
  font-size: 13px;
  line-height: 1.6;
  color: #56657a;
}

/* ----------------------------------------
   モーダル（body 直下。録音・ニックネーム・読み込み中）
   ---------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.5);
}

#voiceModal {
  background: none;
}

.modal-content {
  padding: 30px;
  background: #fff;
  border-radius: 20px;
  text-align: center;
}

/* 録音モーダル（aiHina と同じ見た目） */
.modal-content.wrapMic {
  position: relative;
  width: 290px;
  height: 290px;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  overflow: visible;
}

.volumeCanvas,
.bigMic {
  position: absolute;
  inset: 0;
  margin: auto;
  pointer-events: none;
}

.bigMic {
  width: 75px;
}

.volumeCanvas {
  background-color: #fff;
  border-radius: 151px;
}

.wrapMicFukidashi2 {
  position: absolute;
  z-index: 1;
  width: 169px;
  top: -149px;
  right: 0;
  bottom: 0;
  left: -479px;
  margin: auto;
}

.micFukidashi2 {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 100%;
  transform: scale(-1, 1);
}

.wrapMicFukidashi2 div {
  position: absolute;
  inset: 0;
  margin: auto;
  height: 88px;
  font-weight: bold;
  line-height: 1.5;
}

/* 完了／キャンセル。⚠️ teacher-free.css の img { max-width: 100% } が効くので、箱の幅を決めて画像の max-width を外す
   （旧 UI の left/right だけの指定だと箱の幅が 0 になり、2 つのボタンが幅 0 で消えていた） */
.wrapRecordOKC {
  position: absolute;
  top: 0;
  bottom: -178px;
  left: 296px;
  margin: auto 0;
  width: 218px;
  height: 100px;
  white-space: nowrap;
}

.recordOK {
  width: 100px;
  max-width: none;
  height: 100px;
  margin-right: 18px;
  cursor: pointer;
}

.recordCancel {
  width: 100px;
  max-width: none;
  height: 100px;
  cursor: pointer;
}

/* ニックネーム変更モーダル（白い箱＋銀縁。free.css の .free-dialog に寄せた） */
#nicknameModal {
  z-index: 2100;
}

.nickname-modal-content {
  position: relative;
  width: 92%;
  max-width: 540px;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 24px 22px 20px;
  background: #fff;
  border: 6px solid #dfe6f2;
  border-radius: 22px;
  box-shadow: 0 0 0 3px var(--tf-silver-d, #8f9cad), 0 14px 30px rgba(0, 0, 0, 0.35);
  text-align: center;
  color: var(--tf-ink, #22303f);
}

.modal-close-btn {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 26px;
  color: #8a97a8;
  cursor: pointer;
}

.modal-close-btn:hover {
  color: var(--tf-ink, #22303f);
}

.nickname-modal-title {
  margin-bottom: 8px;
  font-size: 20px;
  font-weight: 900;
  color: var(--tf-navy, #123a7a);
}

.nickname-modal-description {
  margin-bottom: 12px;
  font-size: 14px;
  color: #56657a;
}

/* 漢字・英字の今の名前（マスには入れない） */
.nickname-current {
  margin: -4px 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--tf-navy, #123a7a);
}

/* 名前のマス（2026-11-08〜 コードブレイバーの勇者の登録書と同じ6マス・キーボード） */
.nickname-slots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.nickname-slot {
  width: 44px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  background: #f3f7fd;
  border: 3px solid var(--tf-silver, #c9d3df);
  border-radius: 10px;
  font-size: 26px;
  font-weight: 900;
  color: var(--tf-navy, #123a7a);
}

/* 次に入るマス */
.nickname-slot.is-next {
  border-color: var(--tf-blue, #2f86ea);
  box-shadow: 0 0 0 3px rgba(47, 134, 234, 0.25);
}

.nickname-error {
  min-height: 20px;
  margin: 6px 0;
  font-size: 13px;
  font-weight: 700;
  color: #e8414f;
}

/* 文字の表（1行11マス。6列目は左右の表のあいだのすき間） */
.nickname-keys {
  display: grid;
  grid-template-columns: repeat(5, 1fr) 10px repeat(5, 1fr);
  gap: 5px;
  margin-bottom: 12px;
}

.nickname-key {
  height: 36px;
  padding: 0;
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  background: linear-gradient(180deg, var(--tf-blue-l, #5db2ff), var(--tf-blue, #2f86ea));
  border: none;
  border-radius: 8px;
  box-shadow: 0 3px 0 var(--tf-blue-d, #1a63c8);
  cursor: pointer;
}

.nickname-key:active {
  transform: translateY(3px);
  box-shadow: none;
}

.nickname-key--blank {
  visibility: hidden;
}

.nickname-key:focus-visible,
.nickname-tool-btn:focus-visible {
  outline: 3px solid var(--tf-navy, #123a7a);
  outline-offset: 2px;
}

@media (hover: hover) {
  .nickname-key:hover {
    filter: brightness(1.1);
  }
}

/* カナ・1字消す */
.nickname-tools {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.nickname-tool-btn {
  padding: 7px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.4;
  color: var(--tf-navy, #123a7a);
  background: #fff;
  border: 3px solid var(--tf-silver, #c9d3df);
  border-radius: 12px;
  cursor: pointer;
}

.nickname-tool-btn rt {
  font-size: 0.55em;
}

@media (max-width: 560px) {
  .nickname-modal-content { padding: 22px 10px 16px; }
  .nickname-slots { gap: 5px; }
  .nickname-slot { width: 38px; height: 44px; font-size: 22px; }
  .nickname-keys { gap: 3px; grid-template-columns: repeat(5, 1fr) 6px repeat(5, 1fr); }
  .nickname-key { height: 32px; font-size: 15px; border-radius: 6px; }
}

.nickname-modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.nickname-save-btn,
.nickname-cancel-btn {
  padding: 11px 26px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

/* 進む（青） */
.nickname-save-btn {
  background: linear-gradient(180deg, var(--tf-blue-l, #5db2ff), var(--tf-blue, #2f86ea));
  color: #fff;
  border: none;
  box-shadow: 0 3px 0 var(--tf-blue-d, #1a63c8);
}

.nickname-save-btn:disabled {
  background: #ccc;
  box-shadow: none;
  cursor: not-allowed;
}

/* 戻る（白） */
.nickname-cancel-btn {
  background: #fff;
  color: var(--tf-ink, #22303f);
  border: 3px solid var(--tf-silver, #c9d3df);
}

.nickname-cancel-btn:hover {
  background: #f3f6fa;
}

/* 読み込み中（音声の文字起こし中など） */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.55);
}

.spinner {
  width: 60px;
  height: 60px;
  border: 6px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: tf-chat-spin 1s linear infinite;
}

/* ----------------------------------------
   トースト（#toastContainer。チャット履歴に残さないお知らせ）
   ---------------------------------------- */

.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: 10000;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 400px;
  padding: 14px 22px;
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
  color: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  pointer-events: auto;
  animation: tf-chat-toast-in 0.3s ease-out;
}

.toast::before {
  content: '⚠️';
  font-size: 20px;
}

/* ニックネームを変えたときなどのうれしいお知らせ */
.toast.toast-success {
  background: linear-gradient(135deg, #4ecdc4, #44a08d);
}

.toast.toast-success::before {
  content: '✅';
}

.toast.toast-hide {
  animation: tf-chat-toast-out 0.3s ease-in forwards;
}

@media (max-width: 480px) {
  .toast-container {
    top: 10px;
    left: 10px;
    right: 10px;
    transform: none;
  }

  .toast {
    max-width: 100%;
    padding: 12px 16px;
    font-size: 14px;
  }
}

/* ----------------------------------------
   アイコン選択（ユーザーのアバターを押すと開く。openAvatarSelectorTeacher）
   ---------------------------------------- */

.avatar-selector-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.5);
}

.avatar-selector-popup {
  width: 90%;
  max-width: 400px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 6px solid #dfe6f2;
  border-radius: 20px;
  box-shadow: 0 0 0 3px var(--tf-silver-d, #8f9cad), 0 14px 30px rgba(0, 0, 0, 0.35);
}

.avatar-selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(180deg, #5db2ff, #2f86ea 50%, #1e63c6);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
}

.avatar-selector-close {
  padding: 0 4px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.avatar-selector-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
}

.avatar-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border: 3px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.avatar-option:hover {
  background: #fff8e1;
}

.avatar-option.selected {
  border-color: var(--tf-yellow, #ffcf1f);
  background: #fffde7;
}

.avatar-option img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #f5f5f5;
  border-radius: 10px;
}

.avatar-option-name {
  max-width: 70px;
  margin-top: 4px;
  font-size: 11px;
  text-align: center;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-no-monsters {
  padding: 20px;
  text-align: center;
  font-size: 14px;
  color: #888;
}

@media (max-width: 480px) {
  .avatar-selector-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .avatar-option img {
    width: 48px;
    height: 48px;
  }
}

/* ----------------------------------------
   お知らせ（notices.js）のモーダル。
   ベル（.notice-icon-wrapper）は notices.js が #hamburgerButton の隣にしか置かない＝新しいページでは出ない。
   緊急のお知らせのモーダルは body に出るので、その見た目だけ持ってくる
   ---------------------------------------- */

.notice-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
}

.notice-modal {
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.notice-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.notice-modal-header h3 {
  flex: 1;
  margin: 0;
  padding-right: 16px;
  font-size: 18px;
  color: #333;
}

.notice-modal-close {
  padding: 0;
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: #999;
  cursor: pointer;
}

.notice-modal-date {
  padding: 12px 20px;
  font-size: 13px;
  color: #888;
  background: #f8f9fa;
}

.notice-modal-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.7;
  color: #444;
}

.notice-modal-content p {
  margin: 0 0 1em;
}

.notice-modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid #eee;
}

.notice-modal-close-btn {
  padding: 10px 24px;
  background: var(--tf-blue, #2f86ea);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.urgent-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.8);
}

.urgent-modal {
  width: 100%;
  max-width: 450px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.urgent-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
  color: #fff;
  border-radius: 16px 16px 0 0;
}

.urgent-icon {
  font-size: 28px;
}

.urgent-modal-header h3 {
  margin: 0;
  font-size: 20px;
}

.urgent-modal-body {
  padding: 24px;
}

.urgent-title {
  margin: 0 0 16px;
  font-size: 18px;
  color: #333;
}

.urgent-content {
  font-size: 15px;
  line-height: 1.7;
  color: #555;
}

.urgent-modal-footer {
  display: flex;
  justify-content: center;
  padding: 20px 24px;
  border-top: 1px solid #eee;
}

.urgent-modal-confirm {
  padding: 14px 40px;
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}

/* ----------------------------------------
   keyframes（B と名前が重ならないよう tf-chat-）
   ---------------------------------------- */

@keyframes tf-chat-message-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tf-chat-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tf-chat-dot {
  0% { opacity: 0; }
  25% { opacity: 1; }
  50% { opacity: 1; }
  75% { opacity: 0; }
  100% { opacity: 0; }
}

@keyframes tf-chat-spin {
  to { transform: rotate(360deg); }
}

@keyframes tf-chat-history-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes tf-chat-toast-in {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tf-chat-toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .message,
  .typing-indicator,
  .history-panel,
  .history-item,
  .toast {
    animation: none;
  }
}
