/* AIに聞く（ページ右下のボタンとチャット画面）。2026-11-05 モック */
.ask-fab { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; align-items: center; gap: 8px; height: 48px; padding: 0 18px 0 14px; border: 0; border-radius: 999px; background: var(--green); color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .04em; cursor: pointer; box-shadow: 0 6px 20px rgba(20,80,63,.28); transition: transform .15s, background .15s; }
.ask-fab:hover { background: var(--green-d); transform: translateY(-1px); }
.ask-fab svg { flex: none; }
body:has(.player-bar) .ask-fab { bottom: calc(var(--bar-h) + 14px); }  /* 再生バーのあるページ（時事ネタ・単元）はバーの上に。2026-11-05 単元ページで速度・音声のボタンと重なっていた */
.ask-fab[aria-expanded="true"] { display: none; }

.ask-panel { position: fixed; right: 16px; bottom: 16px; z-index: 70; width: 384px; height: min(600px, calc(100vh - 32px)); display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 48px rgba(24,33,43,.22); overflow: hidden; }
body:has(.player-bar) .ask-panel { bottom: calc(var(--bar-h) + 12px); height: min(600px, calc(100vh - var(--bar-h) - 28px)); }
.ask-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); background: #f9faf7; }
.ask-head h2 { margin: 0; font-size: 15px; letter-spacing: .04em; color: var(--green-d); }
.ask-beta { font-size: 11px; font-weight: 700; color: var(--amber); border: 1px solid currentColor; border-radius: 5px; padding: 0 5px; line-height: 1.6; }
.ask-close { margin-left: auto; width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.ask-close:hover { background: #eef0eb; color: var(--ink); }

.ask-ctx { display: flex; align-items: center; gap: 6px; padding: 7px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.ask-ctx b { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.ask-ctx .badge { font-size: 11px; flex: none; }

.ask-log { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.ask-intro { font-size: 14px; line-height: 1.75; }
.ask-intro p { margin: 0 0 8px; }
.ask-sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-sugg button { border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 4px 12px; font-size: 13px; line-height: 1.6; cursor: pointer; text-align: left; }
.ask-sugg button:hover { border-color: var(--green); color: var(--green-d); }
.ask-msg { max-width: 92%; font-size: 14px; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.ask-msg.q { align-self: flex-end; background: var(--green); color: #fff; border-radius: 14px 14px 4px 14px; padding: 8px 12px; }
.ask-msg.q .ask-quote { display: block; font-size: 12px; opacity: .85; border-left: 2px solid rgba(255,255,255,.6); padding-left: 8px; margin-bottom: 4px; }
.ask-msg.a { align-self: flex-start; background: #f1f3ee; border-radius: 14px 14px 14px 4px; padding: 9px 13px; }
.ask-msg.a [lang="en"] { font-family: var(--en); }
.ask-msg.a.typing::after { content: "▍"; color: var(--green); animation: ask-blink 1s steps(2) infinite; }
@keyframes ask-blink { 50% { opacity: 0; } }
.ask-fb { display: flex; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--muted); white-space: normal; }
.ask-fb button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 0 8px; font-size: 12px; line-height: 1.9; cursor: pointer; color: var(--muted); }
.ask-fb button[aria-pressed="true"] { border-color: var(--green); color: var(--green-d); background: #e8f2ee; }
.ask-err { align-self: center; font-size: 13px; color: #9b2c1f; }

.ask-foot { border-top: 1px solid var(--line); padding: 8px 12px 10px; background: #fff; }
.ask-ts:not(:empty) { margin-bottom: 6px; }
.ask-sel { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; color: var(--muted); background: #fff8e6; border: 1px solid #f0dca8; border-radius: 8px; padding: 4px 6px 4px 10px; margin-bottom: 6px; }
.ask-sel span { flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ask-sel button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.ask-form { display: flex; align-items: flex-end; gap: 8px; }
.ask-form textarea { flex: 1; min-height: 42px; max-height: 120px; resize: none; border: 1.5px solid var(--line); border-radius: 12px; padding: 9px 12px; font: inherit; font-size: 15px; line-height: 1.5; color: var(--ink); background: #fff; }
.ask-form textarea:focus { outline: none; border-color: var(--green); }
.ask-send { flex: none; width: 42px; height: 42px; border: 0; border-radius: 12px; background: var(--green); color: #fff; display: grid; place-items: center; cursor: pointer; }
.ask-send:disabled { background: #c9d0c8; cursor: default; }
.ask-note { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 11px; line-height: 1.6; color: var(--muted); }
.ask-note a { color: var(--muted); }
.ask-count.over { color: #9b2c1f; font-weight: 700; }

/* モック確認用（本番では出さない） */
.ask-debug { font-size: 11px; color: var(--muted); }
.ask-debug summary { cursor: pointer; }
.ask-debug pre { max-height: 220px; overflow: auto; background: #18212b; color: #dfe6e2; padding: 8px; border-radius: 8px; white-space: pre-wrap; font-size: 11px; line-height: 1.5; }

@media (max-width: 600px) {
  .ask-fab { right: 12px; height: 44px; font-size: 14px; padding: 0 14px 0 12px; }
  body:has(.player-bar) .ask-fab { bottom: calc(var(--bar-h) + 10px); }
  .ask-panel, body:has(.player-bar) .ask-panel { left: 0; right: 0; bottom: 0; width: auto; height: 86vh; height: 86dvh; border-radius: 16px 16px 0 0; }
}
@media (prefers-reduced-motion: reduce) { .ask-fab { transition: none; } .ask-msg.a.typing::after { animation: none; } }
