.pa-widget {
  --pa-bg: #fff; --pa-surface: #f4f6fa; --pa-text: #172338;
  --pa-muted: #526176; --pa-line: #c5cedb; --pa-accent: #214ed5;
  color-scheme: light dark; color: var(--pa-text);
  font-family: "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
  font-size: 15px; line-height: 1.65;
}
@media (prefers-color-scheme: dark) {
  .pa-widget { --pa-bg: #141c2a; --pa-surface: #202d40; --pa-text: #eff3fb; --pa-muted: #bbc8dc; --pa-line: #50627c; --pa-accent: #a6c2ff; }
}
[data-theme="light"] .pa-widget { --pa-bg: #fff; --pa-surface: #f4f6fa; --pa-text: #172338; --pa-muted: #526176; --pa-line: #c5cedb; --pa-accent: #214ed5; color-scheme: light; }
[data-theme="dark"] .pa-widget { --pa-bg: #141c2a; --pa-surface: #202d40; --pa-text: #eff3fb; --pa-muted: #bbc8dc; --pa-line: #50627c; --pa-accent: #a6c2ff; color-scheme: dark; }
.pa-widget *, .pa-widget *::before, .pa-widget *::after { box-sizing: border-box; }
.pa-widget button, .pa-widget select, .pa-widget textarea { font: inherit; }
.pa-widget button, .pa-widget select, .pa-widget summary { min-height: 44px; }
.pa-widget button { cursor: pointer; border: 1px solid var(--pa-line); border-radius: 10px; padding: 9px 15px; background: var(--pa-bg); color: var(--pa-text); }
.pa-widget button:disabled, .pa-widget select:disabled { cursor: not-allowed; opacity: .6; }
.pa-widget :focus-visible { outline: 3px solid var(--pa-accent); outline-offset: 3px; }
.pa-widget .pa-launcher, .pa-widget .pa-submit { background: #214ed5; color: white; border-color: #214ed5; font-weight: 700; }
.pa-launcher { position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 50; box-shadow: 0 6px 24px #08172b38; max-width: calc(100vw - 32px); }
.pa-dialog { color: var(--pa-text); background: var(--pa-bg); border: 1px solid var(--pa-line); border-radius: 20px; padding: 0; width: min(620px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 32px); box-shadow: 0 20px 70px #0005; }
.pa-dialog::backdrop { background: #09162d9e; }
html:has(.pa-dialog[open]) { overflow: hidden; }
.pa-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; background: var(--pa-bg); border-bottom: 1px solid var(--pa-line); padding: 18px 24px; z-index: 1; }
.pa-header h2 { font-size: 1.12rem; line-height: 1.4; margin: 0; }
.pa-close { flex-shrink: 0; }
.pa-content { padding: 20px 24px 24px; }
.pa-intro { margin: 0 0 12px; font-size: .9rem; line-height: 1.6; }
/* 回答モデル・選択欄・処理地域を1行に並べ，狭い幅では処理地域を次の行へ折り返す． */
.pa-model-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.pa-model-label { font-weight: 700; margin: 0; }
.pa-select, .pa-question { width: 100%; min-width: 0; border: 1px solid var(--pa-line); border-radius: 10px; padding: 10px 12px; background: var(--pa-bg); color: var(--pa-text); font-size: 16px; }
.pa-model-row .pa-select { flex: 1 1 11rem; width: auto; max-width: 18rem; padding: 8px 10px; }
.pa-region { flex: 1 1 auto; min-width: 0; margin: 0; color: var(--pa-muted); font-size: .8rem; font-weight: 600; overflow-wrap: anywhere; }
.pa-help, .pa-limit, .pa-count, .pa-remaining { color: var(--pa-muted); font-size: .82rem; }
.pa-help { margin: 6px 0 12px; }
/* 送信先・会話の扱い・利用回数などの説明は1つの折りたたみにまとめる． */
.pa-guide { background: var(--pa-surface); border-radius: 10px; padding: 0 12px; margin: 10px 0 12px; font-size: .84rem; }
.pa-guide summary { cursor: pointer; display: flex; align-items: center; font-weight: 600; padding: 4px 0; }
.pa-guide[open] summary { border-bottom: 1px solid var(--pa-line); }
.pa-guide summary { list-style: none; gap: 8px; }
.pa-guide summary::-webkit-details-marker { display: none; }
/* flex指定で既定の開閉印が消えるため，三角を自前で描き開閉で回転させる． */
.pa-guide summary::before { content: ""; flex: 0 0 auto; width: 0; height: 0; border-style: solid; border-width: 5px 0 5px 7px; border-color: transparent transparent transparent currentColor; transition: transform .15s ease; }
.pa-guide[open] summary::before { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .pa-guide summary::before { transition: none; } }
.pa-guide-section { padding: 8px 0 2px; }
.pa-guide-section + .pa-guide-section { border-top: 1px dashed var(--pa-line); }
.pa-guide .pa-guide-title { margin: 0 0 2px; font-size: .82rem; font-weight: 700; line-height: 1.5; color: var(--pa-text); }
.pa-guide p { margin: 0 0 6px; color: var(--pa-muted); font-size: .82rem; line-height: 1.6; overflow-wrap: anywhere; }
.pa-guide .pa-limit { margin: 0 0 6px; }
.pa-messages { display: grid; gap: 12px; }
.pa-message { min-width: 0; padding: 14px 16px; border: 1px solid var(--pa-line); border-radius: 12px; }
.pa-message-user { background: var(--pa-surface); margin-left: 24px; }
.pa-message h3 { margin: 0 0 6px; font-size: .85rem; color: var(--pa-muted); }
.pa-answer { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.pa-sources { padding-left: 20px; margin: 12px 0 0; font-size: .86rem; overflow-wrap: anywhere; }
.pa-sources a { color: var(--pa-accent); text-decoration: underline; text-underline-offset: 3px; }
/* 最新の質問候補だけを質問欄の直上に置く．候補がないときは hidden で隠す． */
.pa-quick-replies { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; }
.pa-quick-replies[hidden] { display: none; }
.pa-quick-replies-label { flex-basis: 100%; margin: 0; color: var(--pa-muted); font-size: .78rem; font-weight: 700; }
.pa-quick-reply { min-height: 40px !important; padding: 7px 11px !important; border-color: var(--pa-accent) !important; color: var(--pa-accent) !important; font-size: .86rem !important; text-align: left; }
/* 入力欄へ追加済みの候補は控えめにし，先頭の印で「追加済み」と分かるようにする（色だけに頼らない）． */
.pa-quick-reply[aria-pressed="true"] { border-style: dashed !important; border-color: var(--pa-line) !important; background: var(--pa-surface) !important; color: var(--pa-muted) !important; }
.pa-quick-reply[aria-pressed="true"]::before { content: "✓ 追加済み："; font-size: .78rem; font-weight: 700; }
.pa-status { font-size: .84rem; margin: 10px 0; overflow-wrap: anywhere; }
.pa-status:empty { display: none; }
.pa-form { border-top: 1px solid var(--pa-line); padding-top: 8px; }
.pa-form-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.pa-form .pa-question-label { display: block; font-weight: 700; margin: 0; }
/* 会話リセットは質問ラベルの右に，文字リンク風の控えめなボタンとして置く． */
.pa-widget .pa-reset { flex-shrink: 0; border-color: transparent; background: transparent; color: var(--pa-muted); font-size: .8rem; padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px; }
.pa-question { display: block; resize: vertical; min-height: 90px; max-height: 260px; }
.pa-form-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.pa-form-meta { flex: 1 1 auto; min-width: 0; margin: 0; line-height: 1.5; }
.pa-remaining:empty { display: none; }
.pa-remaining::before { content: "・"; }
.pa-form .pa-record-notice { margin: 6px 0 0; font-size: .78rem; line-height: 1.5; overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .pa-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 14px; }
  .pa-header { padding: 12px 14px; gap: 8px; }
  .pa-header h2 { font-size: 1rem; }
  .pa-content { padding: 12px 14px 14px; }
  .pa-message-user { margin-left: 14px; }
}
body.pdf-summary .pa-widget { display: none !important; }
@media print { .pa-widget { display: none !important; } }
