/**
 * AI-CloudTech-Kun（クラテクくん）スタイル
 * チャットベースUI版 - ライトシアンテーマ
 */

/* ===============================================
   カラー変数（薄めの水色グラデーション）
   =============================================== */
:root {
    --aick-primary: #06b6d4;           /* シアン */
    --aick-primary-dark: #0891b2;      /* ダークシアン */
    --aick-primary-light: #22d3ee;     /* ライトシアン */
    --aick-primary-pale: #67e8f9;      /* ペールシアン */
    --aick-accent: #38bdf8;            /* スカイブルー */
    --aick-bg-dark: #0c1929;           /* 背景ダーク */
    --aick-bg-card: #132337;           /* カード背景 */
    --aick-bg-input: #1a3148;          /* 入力欄背景 */
    --aick-border: #2a4a6a;            /* ボーダー */
    --aick-text: #e2e8f0;              /* テキスト */
    --aick-text-muted: #94a3b8;        /* サブテキスト */
    --aick-success: #22c55e;           /* 正解グリーン */
    --aick-error: #ef4444;             /* エラーレッド */
    --aick-orange: #f97316;            /* CloudTechオレンジ */
    --aick-gradient: linear-gradient(135deg, #22d3ee 0%, #06b6d4 50%, #0891b2 100%);
    --aick-gradient-light: linear-gradient(135deg, #67e8f9 0%, #22d3ee 100%);
}

/* ===============================================
   AIボタン
   =============================================== */
.aick-btn-container {
    display: block !important;
    position: relative !important;
    margin: 10px 0 15px 0 !important;
    padding: 0 !important;
    text-align: left !important;
}

.aick-ask-btn {
    display: inline-flex !important;
    position: relative !important;
    align-items: center;
    gap: 8px;
    background: var(--aick-gradient);
    color: #fff !important;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.35);
    vertical-align: middle;
    z-index: 1;
}

.aick-ask-btn.aick-inline-btn {
    margin-left: 15px !important;
    padding: 8px 16px;
    font-size: 13px;
}

.aick-ask-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5);
    background: var(--aick-gradient-light);
}

.aick-ask-btn:active {
    transform: translateY(0);
}

.aick-ask-btn .aick-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: contain;
    background: rgba(255,255,255,0.2);
    padding: 2px;
}

.aick-inline-btn .aick-icon {
    width: 18px;
    height: 18px;
}

/* ===============================================
   モーダル
   =============================================== */
.aick-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    padding: 20px;
    backdrop-filter: blur(6px);
}

.aick-modal-overlay.active {
    display: flex;
}

.aick-modal {
    background: var(--aick-bg-dark);
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(6, 182, 212, 0.2);
    animation: aickSlideIn 0.3s ease;
    display: flex;
    flex-direction: column;
}

@keyframes aickSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===============================================
   モーダルヘッダー
   =============================================== */
.aick-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--aick-gradient);
    color: #fff;
    flex-shrink: 0;
    flex-wrap: nowrap;
    gap: 8px;
}

.aick-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    flex-shrink: 0;
}

.aick-modal-title .aick-logo {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    object-fit: contain;
    background: rgba(255,255,255,0.2);
    padding: 3px;
}

.aick-modal-title .aick-beta {
    display: inline-block;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.aick-modal-title .aick-subtitle {
    font-size: 13px;
    font-weight: 400;
    opacity: 0.9;
}

.aick-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aick-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ===============================================
   モーダルボディ
   =============================================== */
.aick-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.aick-error {
    display: none;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--aick-error);
    border-radius: 8px;
    padding: 12px 16px;
    color: #fca5a5;
    font-size: 13px;
    margin: 12px 16px 0;
}

.aick-error.active {
    display: block;
}

/* ===============================================
   チャットメッセージエリア
   =============================================== */
.aick-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 問題情報表示 */
.aick-question-info {
    background: var(--aick-bg-card);
    border-radius: 12px;
    padding: 16px;
    border-left: 4px solid var(--aick-primary);
}

.aick-question-header {
    color: var(--aick-primary-light);
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 12px;
}

.aick-question-text {
    color: var(--aick-text);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--aick-border);
}

.aick-choices-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aick-choice-item {
    background: var(--aick-bg-dark);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--aick-text-muted);
    line-height: 1.6;
    border: 1px solid transparent;
}

.aick-choice-item.correct {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.aick-choice-item.selected-wrong {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.aick-choice-item .choice-label {
    font-weight: 700;
    color: var(--aick-primary-light);
}

.aick-choice-item.correct .choice-label {
    color: var(--aick-success);
}

.aick-choice-item.selected-wrong .choice-label {
    color: var(--aick-error);
}

/* ===============================================
   チャットメッセージ
   =============================================== */
.aick-chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.aick-msg-user {
    align-self: flex-end;
}

.aick-msg-assistant {
    align-self: flex-start;
}

.aick-msg-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--aick-text-muted);
    margin-bottom: 8px;
    padding: 0 4px;
}

.aick-msg-header .header-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

/* コピーボタン */
.aick-copy-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 11px;
    padding: 3px 8px;
    margin-left: auto;
    opacity: 0.6;
    transition: all 0.2s ease;
    border-radius: 4px;
    color: var(--aick-text-muted);
}

.aick-copy-btn .copy-icon {
    font-size: 12px;
}

.aick-copy-btn .copy-label {
    font-size: 10px;
}

.aick-copy-btn:hover {
    opacity: 1;
    background: rgba(6, 182, 212, 0.15);
    border-color: rgba(6, 182, 212, 0.3);
    color: var(--aick-primary-light);
}

.aick-copy-btn.copied {
    opacity: 1;
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #4ade80;
}

.aick-copy-btn.copied .copy-icon,
.aick-copy-btn.copied .copy-label {
    color: #4ade80;
}

/* 会話全体コピーボタン */
.aick-copy-all-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    color: var(--aick-primary-light);
    font-size: 12px;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 12px auto;
    width: fit-content;
}

.aick-copy-all-btn:hover {
    background: rgba(6, 182, 212, 0.2);
    border-color: var(--aick-primary);
}

.aick-copy-all-btn.copied {
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.4);
    color: #4ade80;
}

.aick-copy-all-btn .copy-all-icon {
    font-size: 14px;
}

.aick-msg-user .aick-msg-header {
    text-align: right;
    justify-content: flex-end;
}

.aick-msg-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* リンクスタイル */
.aick-msg-content a {
    color: var(--aick-primary-light);
    text-decoration: underline;
    word-break: break-all;
}

.aick-msg-content a:hover {
    color: var(--aick-primary-pale);
}

/* LINE風カラー */
.aick-msg-user .aick-msg-content {
    background: #dcf8c6;  /* 薄いグリーン（LINE風） */
    color: #1a1a1a;
    border-bottom-right-radius: 4px;
    border: none;
}

.aick-msg-assistant .aick-msg-content {
    background: linear-gradient(135deg, rgba(60, 60, 80, 0.95) 0%, rgba(45, 45, 65, 0.9) 100%);
    color: #ffffff;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(100, 100, 120, 0.4);
}

/* キャラ別の吹き出し色 */
.aick-msg-assistant.aick-char-sora .aick-msg-content {
    background: linear-gradient(135deg, rgba(244, 114, 182, 0.2) 0%, rgba(236, 72, 153, 0.12) 100%);
    border-color: rgba(244, 114, 182, 0.4);
    color: #ffffff;
}

.aick-msg-assistant.aick-char-kanata .aick-msg-content {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.2) 0%, rgba(139, 92, 246, 0.12) 100%);
    border-color: rgba(167, 139, 250, 0.4);
    color: #ffffff;
}

.aick-msg-content strong {
    color: #1a1a1a;
    font-weight: 700;
}

.aick-msg-assistant .aick-msg-content strong {
    color: #facc15;
}

.aick-msg-assistant .aick-msg-content strong.highlight {
    color: #e65100;
}

/* 回答予定キャラ表示 */
.aick-char-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.1) 0%, rgba(34, 211, 238, 0.05) 100%);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    margin: 8px 0;
    animation: aickFadeIn 0.3s ease;
}

.aick-char-preview.sora {
    background: linear-gradient(135deg, rgba(244, 114, 182, 0.15) 0%, rgba(236, 72, 153, 0.08) 100%);
    border-color: rgba(244, 114, 182, 0.4);
}

.aick-char-preview.kanata {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.15) 0%, rgba(139, 92, 246, 0.08) 100%);
    border-color: rgba(167, 139, 250, 0.4);
}

.aick-char-preview img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.aick-char-preview-text {
    font-size: 13px;
    color: var(--aick-text);
}

/* ===============================================
   マークダウンスタイル
   =============================================== */
.aick-msg-content .md-h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--aick-primary-light);
    margin: 16px 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--aick-border);
}

.aick-msg-content .md-h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--aick-accent);
    margin: 14px 0 6px 0;
}

.aick-msg-content .md-h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--aick-primary-light);
    margin: 12px 0 4px 0;
}

.aick-msg-content .md-code {
    background: var(--aick-bg-dark);
    color: var(--aick-success);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
}
.aick-msg-content .md-code-block {
    position: relative;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 8px;
    margin: 10px 0;
    overflow: hidden;
}
.aick-msg-content .md-code-block pre {
    margin: 0;
    padding: 12px 14px;
    overflow-x: auto;
}
.aick-msg-content .md-code-block code {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-word;
}
.aick-msg-content .md-code-lang {
    display: block;
    padding: 4px 14px;
    font-size: 11px;
    color: var(--aick-text-muted);
    background: rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.aick-msg-content .md-hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    margin: 16px 0;
}

.aick-msg-content .md-list-item {
    display: flex;
    align-items: flex-start;
    margin: 6px 0;
    line-height: 1.6;
}
.aick-msg-content .md-list-text {
    flex: 1;
    min-width: 0;
}

.aick-msg-content .md-list-num {
    color: var(--aick-primary-light);
    font-weight: 700;
    min-width: 24px;
    flex-shrink: 0;
}

.aick-msg-content .md-list-bullet {
    color: var(--aick-accent);
    min-width: 16px;
    flex-shrink: 0;
}

.aick-msg-content em {
    font-style: italic;
    color: #7dd3fc;
}

/* ===============================================
   タイピング・思考中アニメーション
   =============================================== */
.aick-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.aick-typing span {
    width: 8px;
    height: 8px;
    background: var(--aick-primary-light);
    border-radius: 50%;
    animation: aickTyping 1.4s infinite;
}

.aick-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.aick-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes aickTyping {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* 思考中表示（リッチ版） */
.aick-thinking {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
}

.aick-thinking-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Lottie + ロゴオーバーレイコンテナ */
.aick-thinking .thinking-icon-container {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.aick-thinking .thinking-lottie {
    width: 56px;
    height: 56px;
}

.aick-thinking .thinking-logo-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    opacity: 0.4;
    pointer-events: none;
}

/* キャラクターアイコン（考え中） */
.aick-thinking .thinking-char-icon {
    width: 44px;
    height: 44px;
    object-fit: contain;
    animation: gentleBounce 2s ease-in-out infinite;
    flex-shrink: 0;
}

@keyframes gentleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* 旧形式互換 */
.aick-thinking .thinking-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    animation: aickThinkingPulse 2s ease-in-out infinite;
    flex-shrink: 0;
}

.aick-thinking .thinking-emoji {
    font-size: 40px;
    animation: aickThinkingBounce 2s ease-in-out infinite;
}

@keyframes aickThinkingPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.85;
    }
}

@keyframes aickThinkingBounce {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-4px) rotate(-5deg);
    }
    75% {
        transform: translateY(-4px) rotate(5deg);
    }
}

.aick-thinking .thinking-text {
    font-size: 14px;
    color: var(--aick-text);
    line-height: 1.6;
}

.aick-thinking .thinking-main {
    font-weight: 600;
    margin-bottom: 4px;
}

.aick-thinking .thinking-sub {
    font-size: 13px;
    color: var(--aick-text-muted);
    font-style: italic;
}

/* ===============================================
   入力エリア
   =============================================== */
.aick-chat-input-area {
    padding: 16px;
    background: var(--aick-bg-dark);
    border-top: 1px solid var(--aick-border);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-shrink: 0;
}

.aick-chat-input {
    flex: 1;
    background: var(--aick-bg-input);
    border: 2px solid var(--aick-border);
    border-radius: 12px;
    padding: 12px 16px;
    color: #ffffff;
    font-size: 14px;
    resize: vertical; /* PCでドラッグリサイズ可能 */
    min-height: 44px;
    max-height: 200px; /* 最大高さを増加 */
    line-height: 1.5;
    transition: border-color 0.2s ease, height 0.1s ease;
    overflow-y: auto;
}

.aick-chat-input:focus {
    outline: none;
    border-color: var(--aick-primary);
    color: #ffffff;
}

.aick-chat-input::placeholder {
    color: var(--aick-text-muted);
}

.aick-send-btn {
    background: var(--aick-gradient);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.aick-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.4);
}

.aick-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.aick-stop-btn {
    background: linear-gradient(135deg, var(--aick-error) 0%, #dc2626 100%);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.aick-stop-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* 入力ヒント（PC用） */
.aick-input-hint {
    display: none; /* デフォルトは非表示、PCのみ表示 */
    font-size: 12px;
    color: var(--aick-text-muted);
}

@media (min-width: 1025px) {
    .aick-input-hint {
        display: block;
    }
}

/* ===============================================
   システムメッセージ
   =============================================== */
.aick-msg-system {
    align-self: center;
}

.aick-msg-system .aick-msg-content {
    background: transparent;
    color: var(--aick-text-muted);
    font-size: 12px;
    padding: 8px 12px;
    border: none;
}

/* ===============================================
   利用回数表示
   =============================================== */
.aick-usage-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px 16px 10px;
    background: var(--aick-bg-dark);
    font-size: 12px;
    color: var(--aick-text-muted);
    flex-shrink: 0;
    border-top: 1px solid var(--aick-border);
    position: relative;
}

.aick-usage-count {
    display: flex;
    align-items: center;
    gap: 6px;
}

.aick-usage-count strong {
    color: var(--aick-primary-light);
}

.aick-privacy-note {
    font-size: 10px;
    color: var(--aick-text-muted);
    opacity: 0.7;
    margin-top: 4px;
}

/* ?ボタン */
.aick-info-btn {
    background: rgba(6, 182, 212, 0.2);
    border: 1px solid var(--aick-primary);
    color: var(--aick-primary-light);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aick-info-btn:hover {
    background: var(--aick-primary);
    color: #fff;
}

/* フィードバックボタン */
.aick-feedback-btn {
    background: rgba(251, 191, 36, 0.2);
    border: 1px solid #fbbf24;
    color: #fbbf24;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    margin-left: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.aick-feedback-btn:hover {
    background: #fbbf24;
    color: #1a1a2e;
    transform: scale(1.1);
}

/* ===============================================
   利用上限ポップオーバー
   =============================================== */
.aick-limit-popover {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 10px;
    z-index: 1000;
}

.aick-limit-popover.active {
    display: block;
    animation: aickPopoverIn 0.2s ease;
}

@keyframes aickPopoverIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.aick-popover-content {
    background: var(--aick-bg-card);
    border: 1px solid var(--aick-border);
    border-radius: 12px;
    padding: 16px;
    min-width: 280px;
    max-width: 340px;
    max-height: 65vh;
    max-height: 65dvh; /* キーボード表示時に縮む */
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    scrollbar-width: thin;
    scrollbar-color: rgba(6, 182, 212, 0.4) transparent;
}

.aick-popover-content::-webkit-scrollbar {
    width: 6px;
}

.aick-popover-content::-webkit-scrollbar-track {
    background: transparent;
}

.aick-popover-content::-webkit-scrollbar-thumb {
    background: rgba(6, 182, 212, 0.4);
    border-radius: 3px;
}

.aick-popover-content::-webkit-scrollbar-thumb:hover {
    background: rgba(6, 182, 212, 0.6);
}

.aick-popover-content::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--aick-bg-card);
}

.aick-current-plan {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--aick-text);
}

.aick-current-plan strong {
    color: var(--aick-primary-light);
}

.aick-limit-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--aick-text-muted);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--aick-border);
}

.aick-limit-table {
    margin-bottom: 12px;
}

.aick-limit-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 12px;
    color: var(--aick-text);
    border-bottom: 1px solid rgba(42, 74, 106, 0.5);
}

.aick-limit-row:last-child {
    border-bottom: none;
}

.aick-limit-row span:last-child {
    color: var(--aick-primary-light);
    font-weight: 600;
}

.aick-limit-note {
    font-size: 11px;
    color: var(--aick-text-muted);
    line-height: 1.5;
    margin-bottom: 12px;
    padding: 8px;
    background: rgba(148, 163, 184, 0.1);
    border-radius: 6px;
}

.aick-upgrade-link {
    display: block;
    text-align: center;
    background: var(--aick-gradient);
    color: #fff !important;
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.aick-upgrade-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

/* ===============================================
   ご利用ガイドライン（ポップオーバー内）
   =============================================== */
.aick-guideline {
    margin-top: 14px;
    margin-bottom: 12px;
    padding: 12px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(6, 182, 212, 0.35);
    border-radius: 8px;
}

.aick-guideline-header {
    font-size: 13px;
    font-weight: 700;
    color: var(--aick-primary-light);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(6, 182, 212, 0.25);
}

.aick-guideline-intro {
    font-size: 12px;
    color: #e2e8f0;
    line-height: 1.6;
    margin-bottom: 10px;
}

.aick-guideline-intro strong {
    color: #fff;
}

.aick-guideline-section {
    margin-bottom: 10px;
    padding: 8px 10px;
    border-radius: 6px;
}

.aick-guideline-good {
    background: rgba(34, 197, 94, 0.12);
    border-left: 3px solid rgba(34, 197, 94, 0.7);
}

.aick-guideline-bad {
    background: rgba(239, 68, 68, 0.12);
    border-left: 3px solid rgba(239, 68, 68, 0.7);
}

.aick-guideline-label {
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.aick-guideline-section ul {
    margin: 0;
    padding-left: 18px;
    list-style: disc;
}

.aick-guideline-section li {
    font-size: 11.5px;
    color: #cbd5e1;
    line-height: 1.6;
    margin: 2px 0;
}

.aick-guideline-warn {
    font-size: 11.5px;
    color: #fde68a;
    line-height: 1.5;
    margin: 8px 0 10px;
    padding: 8px 10px;
    background: rgba(245, 158, 11, 0.12);
    border-left: 3px solid rgba(245, 158, 11, 0.7);
    border-radius: 6px;
}

.aick-guideline-link {
    display: block;
    text-align: center;
    color: var(--aick-primary-light) !important;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    padding: 6px;
    border: 1px solid rgba(6, 182, 212, 0.4);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.aick-guideline-link:hover {
    background: rgba(6, 182, 212, 0.15);
    color: #fff !important;
}

/* ===============================================
   上限到達・未登録メッセージ
   =============================================== */
.aick-limit-reached {
    text-align: center;
    padding: 40px 20px;
}

.aick-limit-reached .limit-icon {
    font-size: 56px;
    margin-bottom: 20px;
}

.aick-limit-reached h3 {
    color: var(--aick-text);
    margin: 0 0 12px 0;
    font-size: 20px;
}

.aick-limit-reached p {
    color: var(--aick-text-muted);
    margin: 0 0 8px 0;
    line-height: 1.8;
}

.aick-limit-reached .current-plan-info {
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 16px auto;
    max-width: 280px;
    font-size: 14px;
    color: var(--aick-text);
}

.aick-limit-reached .current-plan-info strong {
    color: var(--aick-primary-light);
}

.aick-limit-reached .limit-table-mini {
    margin: 16px auto;
    max-width: 260px;
    text-align: left;
}

.aick-limit-reached .limit-table-mini .limit-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 12px;
    color: var(--aick-text-muted);
    border-bottom: 1px solid var(--aick-border);
}

.aick-limit-reached .limit-table-mini .limit-row:last-child {
    border-bottom: none;
}

.aick-limit-reached .limit-table-mini .limit-row span:last-child {
    color: var(--aick-primary-light);
}

.aick-limit-reached .limit-note-mini {
    font-size: 11px;
    color: var(--aick-text-muted);
    margin: 12px 0;
    line-height: 1.5;
}

.aick-register-btn {
    display: inline-block;
    margin-top: 16px;
    background: var(--aick-gradient) !important;
    color: #fff !important;
    padding: 14px 28px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    transition: all 0.3s ease;
}

.aick-register-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(6, 182, 212, 0.4);
}

/* ===============================================
   マークダウンテーブル
   =============================================== */
/* 列数の多い表はパネル幅では収まらないため、枠内で横スクロールさせる */
.md-table-wrap {
    margin: 12px 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
}

.md-table {
    width: 100%;
    min-width: 320px; /* これ未満に潰れると読めないのでスクロールに委ねる */
    border-collapse: collapse;
    margin: 0;
    font-size: 13px;
    background: var(--aick-bg-dark);
    border-radius: 8px;
    overflow: hidden;
}

.md-table th,
.md-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--aick-border);
}

.md-table th {
    background: var(--aick-bg-input);
    font-weight: 600;
    color: var(--aick-primary-light);
}

.md-table tr:last-child td {
    border-bottom: none;
}

.md-table tr:hover td {
    background: rgba(6, 182, 212, 0.08);
}

/* ===============================================
   Mermaid図表
   =============================================== */
.mermaid-container {
    margin: 16px 0;
    padding: 16px;
    background: #ffffff;
    border-radius: 8px;
    overflow-x: auto;
}

.mermaid-container .mermaid {
    display: flex;
    justify-content: center;
}

.mermaid-container svg {
    max-width: 100%;
    height: auto;
}

.mermaid-container .nodeLabel,
.mermaid-container .edgeLabel {
    font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
}

/* Mermaidエラー時のフォールバック */
.mermaid-fallback {
    background: var(--aick-bg-dark);
    border: 1px solid var(--aick-border);
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
}

.mermaid-error-note {
    font-size: 12px;
    color: var(--aick-orange);
    margin-bottom: 8px;
}

.mermaid-code {
    background: var(--aick-bg-input);
    color: var(--aick-text);
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Monaco', 'Consolas', monospace;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    overflow-x: auto;
}

/* ===============================================
   レスポンシブ（PC / デスクトップ）
   =============================================== */
@media (min-width: 1025px) {
    .aick-modal {
        max-width: 900px;
        max-height: 95vh;
    }
    
    .aick-chat-messages {
        padding: 20px 24px;
    }
    
    .aick-chat-message {
        max-width: 80%;
    }
    
    .aick-msg-text {
        font-size: 16px;
        line-height: 1.7;
        padding: 14px 18px;
    }
    
    .aick-question-text {
        font-size: 15px;
        padding: 16px 20px;
    }
    
    .aick-question-text .aick-choice-item {
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .aick-input-area {
        padding: 12px 20px 12px;
    }
    
    .aick-input-wrapper textarea {
        font-size: 15px;
        padding: 14px 16px;
    }
    
    /* PC: フッター横並び1行 */
    .aick-usage-info {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 24px;
        padding: 6px 20px;
        font-size: 13px;
    }
    
    .aick-usage-info .aick-input-hint {
        padding: 0;
        border-top: none;
    }
}

/* ===============================================
   レスポンシブ（タブレット / iPad）
   =============================================== */
@media (max-width: 1024px) and (min-width: 601px) {
    /* タブレットはベースCSSでOK、微調整のみ */
    .aick-char-switch-btn {
        max-width: 160px;
    }
    
    .aick-chat-messages {
        padding: 12px;
    }
    
    .aick-usage-info {
        padding: 5px 12px;
        font-size: 11px;
    }
}

/* ===============================================
   レスポンシブ（スマホ）
   =============================================== */
@media (max-width: 600px) {
    .aick-modal {
        max-height: 95vh; /* 画面いっぱいに表示 */
        border-radius: 16px 16px 0 0;
        margin-top: auto;
        margin-bottom: env(safe-area-inset-bottom, 0); /* iPhoneのホームバー対応 */
    }
    
    .aick-modal-overlay {
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0); /* iPhoneのセーフエリア */
        align-items: flex-end;
    }
    
    .aick-modal-header {
        padding: 12px 16px;
    }
    
    .aick-modal-title {
        font-size: 15px;
        gap: 8px;
    }
    
    .aick-modal-title .aick-logo {
        width: 26px;
        height: 26px;
    }
    
    .aick-modal-title .aick-beta {
        font-size: 9px;
        padding: 1px 4px;
        margin-left: 4px;
    }
    
    .aick-modal-title .aick-subtitle {
        font-size: 11px;
    }
    
    .aick-chat-messages {
        padding: 12px;
        max-height: calc(95vh - 180px); /* フッター分を考慮 */
        flex: 1;
        overflow-y: auto;
    }
    
    .aick-chat-message {
        max-width: 90%;
    }
    
    .aick-question-text {
        font-size: 13px;
    }
    
    .aick-choice-item {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .aick-ask-btn {
        padding: 6px 12px;
        font-size: 12px;
        margin-left: 8px !important;
    }
    
    .aick-ask-btn .aick-icon {
        width: 16px;
        height: 16px;
    }
    
    /* 入力エリア（スマホ） */
    .aick-chat-input-area {
        padding: 10px 12px;
        flex-shrink: 0;
    }
    
    .aick-chat-input {
        padding: 10px 12px;
        font-size: 16px; /* iOS ズーム防止 */
    }
    
    .aick-send-btn,
    .aick-stop-btn {
        width: 40px;
        height: 40px;
    }
    
    /* 利用回数表示（スマホ） */
    .aick-usage-info {
        padding: 6px 12px;
        font-size: 10px;
        flex-shrink: 0;
    }
    
    .aick-limit-popover {
        left: 10px;
        right: 10px;
        transform: none;
    }
    
    .aick-popover-content {
        min-width: auto;
        max-width: none;
        max-height: 70vh;
        max-height: 70dvh;
    }
    
    .aick-popover-content::after {
        left: 70%;
    }
}

/* ===============================================
   フィードバック案内
   =============================================== */
.aick-feedback-prompt {
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(34, 211, 238, 0.1) 100%);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 12px;
    padding: 16px 20px;
    text-align: center;
    margin: 8px 0;
    animation: aickFeedbackSlide 0.4s ease;
}

@keyframes aickFeedbackSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.feedback-prompt-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--aick-primary-light);
    margin-bottom: 6px;
}

.feedback-prompt-text {
    font-size: 12px;
    color: var(--aick-text-muted);
    margin: 0 0 12px 0;
}

.feedback-stars-prompt {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.feedback-star {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--aick-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 4px;
}

.feedback-star:hover {
    color: #fbbf24;
    transform: scale(1.2);
}

/* ===============================================
   フィードバックパネル
   =============================================== */
.aick-feedback-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    animation: aickFadeIn 0.2s ease;
}

@keyframes aickFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.aick-feedback-panel {
    background: var(--aick-bg-dark);
    border-radius: 16px;
    max-width: 450px;
    width: 100%;
    max-height: 80vh;
    max-height: 80dvh;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(6, 182, 212, 0.2);
    animation: aickSlideIn 0.3s ease;
}

.feedback-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--aick-gradient);
    color: #fff;
}

.feedback-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.feedback-panel-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-panel-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.feedback-panel-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 140px);
    max-height: calc(80dvh - 140px);
}

.feedback-section {
    margin-bottom: 20px;
}

.feedback-section:last-child {
    margin-bottom: 0;
}

.feedback-section-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--aick-text);
    margin-bottom: 10px;
}

.feedback-section-label .required {
    color: var(--aick-error);
}

/* 星評価（パネル内） */
.feedback-stars-select {
    display: flex;
    gap: 8px;
    margin-bottom: 6px;
}

.feedback-star-select {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--aick-border);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 4px;
}

.feedback-star-select:hover {
    transform: scale(1.15);
}

.feedback-star-select.selected {
    color: #fbbf24;
}

.feedback-rating-text {
    font-size: 12px;
    color: var(--aick-text-muted);
    margin-left: 4px;
}

/* カテゴリカード */
.feedback-categories {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feedback-category-card {
    display: flex;
    align-items: center;
    background: var(--aick-bg-card);
    border: 1px solid var(--aick-border);
    border-radius: 10px;
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.feedback-category-card:hover {
    border-color: var(--aick-primary);
    background: rgba(6, 182, 212, 0.08);
}

.feedback-category-card input[type="checkbox"] {
    display: none;
}

.feedback-category-card input[type="checkbox"]:checked + .category-label {
    color: var(--aick-primary-light);
}

.feedback-category-card:has(input:checked) {
    border-color: var(--aick-primary);
    background: rgba(6, 182, 212, 0.15);
}

.category-label {
    font-size: 13px;
    color: var(--aick-text);
    transition: color 0.2s ease;
}

/* 自由コメント */
.feedback-comment {
    width: 100%;
    background: var(--aick-bg-input);
    border: 2px solid var(--aick-border);
    border-radius: 10px;
    padding: 12px 14px;
    color: #ffffff;
    font-size: 13px;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.feedback-comment:focus {
    outline: none;
    border-color: var(--aick-primary);
    color: #ffffff;
}

.feedback-comment::placeholder {
    color: var(--aick-text-muted);
}

/* 送信ボタン */
.feedback-panel-footer {
    padding: 16px 20px;
    background: var(--aick-bg-dark);
    border-top: 1px solid var(--aick-border);
}

.feedback-submit-btn {
    width: 100%;
    background: var(--aick-gradient);
    border: none;
    color: #fff;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.feedback-submit-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.4);
}

.feedback-submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.feedback-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* レスポンシブ（フィードバック） */
@media (max-width: 600px) {
    .aick-feedback-panel-overlay {
        padding: 10px;
        align-items: flex-end;
    }
    
    .aick-feedback-panel {
        max-height: 85vh;
        max-height: 85dvh;
        border-radius: 16px 16px 0 0;
    }
    
    .feedback-panel-body {
        max-height: calc(85vh - 140px);
        max-height: calc(85dvh - 140px);
    }
    
    .feedback-star {
        font-size: 24px;
    }
    
    .feedback-star-select {
        font-size: 28px;
    }
}

/* ===============================================
   スクロールバー
   =============================================== */
.aick-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.aick-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.aick-chat-messages::-webkit-scrollbar-thumb {
    background: var(--aick-border);
    border-radius: 3px;
}

.aick-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--aick-primary);
}

/* ===============================================
   キャラクター切り替えUI
   =============================================== */
.aick-header-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.aick-char-switcher {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 3px;
    margin: 0 auto;
    flex: 1;
    justify-content: center;
}

.aick-char-switch-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid transparent;
    color: rgba(255, 255, 255, 0.7);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    max-width: 140px;
}

.aick-char-switch-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.aick-char-switch-btn.active {
    color: #fff;
    font-weight: 600;
}

/* ソラ（速度優先）のテーマカラー */
.aick-char-switch-btn[data-character="sora"].active {
    background: linear-gradient(135deg, #f472b6 0%, #ec4899 100%);
    border-color: #f9a8d4;
}

.aick-char-switch-btn[data-character="sora"].active img {
    border-color: #fff;
}

/* カナタ（品質優先）のテーマカラー */
.aick-char-switch-btn[data-character="kanata"].active {
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 100%);
    border-color: #c4b5fd;
}

.aick-char-switch-btn[data-character="kanata"].active img {
    border-color: #fff;
}

.aick-char-name {
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.aick-char-label {
    font-size: 9px;
    font-weight: 500;
    opacity: 0.8;
    line-height: 1;
}

.aick-char-cost {
    font-size: 9px;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 5px;
    border-radius: 6px;
    line-height: 1;
}

/* キャラクター別メッセージスタイル */
.aick-msg-assistant.aick-char-sora .aick-msg-content {
    background: linear-gradient(135deg, rgba(244, 114, 182, 0.12) 0%, rgba(236, 72, 153, 0.08) 100%);
    border-color: rgba(244, 114, 182, 0.3);
}

.aick-msg-assistant.aick-char-sora .aick-msg-header {
    color: #f9a8d4;
}

.aick-msg-assistant.aick-char-kanata .aick-msg-content {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.12) 0%, rgba(139, 92, 246, 0.08) 100%);
    border-color: rgba(167, 139, 250, 0.3);
}

.aick-msg-assistant.aick-char-kanata .aick-msg-header {
    color: #c4b5fd;
}

.aick-char-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

/* クレジット消費表示 */
.aick-credit-info {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--aick-text-muted);
    margin-left: 8px;
}

.aick-credit-cost {
    color: var(--aick-primary-light);
    font-weight: 600;
}

/* レスポンシブ（キャラクター切り替え） */
@media (max-width: 600px) {
    .aick-modal-header {
        padding: 6px 10px;
        gap: 6px;
    }
    
    .aick-modal-title {
        font-size: 13px;
        gap: 6px;
    }
    
    .aick-modal-title .aick-logo {
        width: 22px;
        height: 22px;
    }
    
    .aick-char-switcher {
        padding: 4px;
        gap: 4px;
    }
    
    .aick-char-switch-btn {
        padding: 5px 8px;
        gap: 6px;
        max-width: none;
    }
    
    .aick-char-switch-btn img {
        width: 26px;
        height: 26px;
    }
    
    .aick-char-label {
        font-size: 8px;
    }
    
    .aick-char-name {
        font-size: 11px;
    }
    
    .aick-char-cost {
        font-size: 8px;
        padding: 1px 4px;
    }
    
    .aick-close-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    /* チャットアイコン（スマホ） */
    .aick-msg-header .header-icon {
        width: 36px;
        height: 36px;
    }
    
    /* 考え中表示（スマホ） */
    .aick-thinking .thinking-icon-container {
        width: 44px;
        height: 44px;
    }
    
    .aick-thinking .thinking-lottie {
        width: 44px;
        height: 44px;
    }
    
    .aick-thinking .thinking-logo-overlay {
        width: 20px;
        height: 20px;
    }
    
    .aick-thinking .thinking-char-icon {
        width: 36px;
        height: 36px;
    }
    
    .aick-thinking .thinking-icon {
        width: 44px;
        height: 44px;
    }
    
    /* 回答予定キャラ（スマホ） */
    .aick-char-preview {
        padding: 10px 12px;
        gap: 10px;
    }
    
    .aick-char-preview img {
        width: 32px;
        height: 32px;
    }
    
    .aick-char-preview-text {
        font-size: 12px;
    }
    
    /* ローディングTIPS（スマホ） */
    .aick-loading-tips {
        font-size: 11px;
        padding: 10px;
    }
}

/* ===============================================
   ローディング中TIPS表示
   =============================================== */
.aick-loading-tips {
    margin-top: 16px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(56, 189, 248, 0.1) 100%);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--aick-text);
    animation: tips-fade-in 0.3s ease-out;
}

@keyframes tips-fade-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aick-loading-tips .tips-text {
    display: inline;
}

.aick-loading-tips .tips-link {
    display: inline;
    color: var(--aick-primary-light);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.aick-loading-tips .tips-link:hover {
    color: var(--aick-accent);
    text-decoration: underline;
}

.aick-loading-tips .tips-link-icon {
    font-size: 11px;
    margin-left: 2px;
}

/* キャラクター別TIPS色味 */
.aick-thinking.sora .aick-loading-tips {
    background: linear-gradient(135deg, rgba(244, 114, 182, 0.15) 0%, rgba(236, 72, 153, 0.08) 100%);
    border-color: rgba(244, 114, 182, 0.3);
}

.aick-thinking.sora .aick-loading-tips .tips-link {
    color: #f472b6;
}

.aick-thinking.sora .aick-loading-tips .tips-link:hover {
    color: #f9a8d4;
}

.aick-thinking.kanata .aick-loading-tips {
    background: linear-gradient(135deg, rgba(167, 139, 250, 0.15) 0%, rgba(139, 92, 246, 0.08) 100%);
    border-color: rgba(167, 139, 250, 0.3);
}

.aick-thinking.kanata .aick-loading-tips .tips-link {
    color: #a78bfa;
}

.aick-thinking.kanata .aick-loading-tips .tips-link:hover {
    color: #c4b5fd;
}

/* コピー時の注意喚起トースト */
.aick-copy-warning-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.95) 0%, rgba(245, 158, 11, 0.95) 100%);
    color: #1f2937;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 90%;
    width: 400px;
    z-index: 100001;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.aick-copy-warning-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.aick-copy-warning-toast .toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.aick-copy-warning-toast .toast-message {
    font-size: 13px;
    line-height: 1.6;
    font-weight: 500;
}

.aick-copy-warning-toast .toast-close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    font-size: 20px;
    color: #1f2937;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 0;
    line-height: 1;
}

.aick-copy-warning-toast .toast-close:hover {
    opacity: 1;
}

/* スマホ向け調整 */
@media (max-width: 600px) {
    .aick-copy-warning-toast {
        bottom: 80px;
        width: calc(100% - 32px);
        max-width: none;
        padding: 14px 16px;
    }
    
    .aick-copy-warning-toast .toast-message {
        font-size: 12px;
    }
}

/* トークン上限で切れた場合の通知 */
.aick-truncate-note {
    margin-top: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15) 0%, rgba(245, 158, 11, 0.1) 100%);
    border: 1px solid rgba(251, 191, 36, 0.4);
    border-radius: 8px;
    color: #b45309;
    font-size: 13px;
    line-height: 1.5;
}

.aick-char-kanata .aick-truncate-note {
    color: #fef3c7;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.25) 0%, rgba(245, 158, 11, 0.15) 100%);
}

.aick-char-sora .aick-truncate-note {
    color: #fef3c7;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.25) 0%, rgba(245, 158, 11, 0.15) 100%);
}

/* AWS公式ドキュメント検索中の表示 */
.aick-searching-note {
    margin-top: 12px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(37, 99, 235, 0.08) 100%);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-radius: 8px;
    color: #1d4ed8;
    font-size: 13px;
    line-height: 1.5;
    animation: aick-searching-pulse 1.5s ease-in-out infinite;
}

.aick-char-kanata .aick-searching-note,
.aick-char-sora .aick-searching-note {
    color: #dbeafe;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(37, 99, 235, 0.15) 100%);
}

@keyframes aick-searching-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ストリーミング中の点滅カーソル */
.aick-streaming-cursor {
    display: inline-block;
    width: 8px;
    height: 18px;
    background: #60a5fa;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: aick-cursor-blink 0.8s infinite;
    border-radius: 2px;
}

@keyframes aick-cursor-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* ===============================================
   ドッキングパネル / ドロワー化
   ===============================================
   従来の中央モーダル（全画面オーバーレイ）を、右端に固定される
   パネルに置き換える。目的は解説エリアとAI会話の同時参照。

   - PC (>=1025px): 右にドッキングし、本文を左に寄せる。幅はドラッグで可変。
   - それ未満        : 右から出るドロワー。折りたたむと画面外に退避。

   このセクションはファイル末尾に置き、先行するモーダル用の定義を
   意図的に上書きしている。
   =============================================== */

:root {
    --aick-panel-width: 420px;
}

/* オーバーレイを「右端のパネル枠」に転用する。
   背景の暗幕とブラーを外すことで、後ろの解説が読める状態にする。 */
.aick-modal-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: var(--aick-panel-width);
    max-width: 100%;
    padding: 0;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    display: none;
    /* 枠自体はクリックを透過させ、後ろの解説を操作できるようにする */
    pointer-events: none;
    overflow: visible;
}

.aick-modal-overlay.active {
    display: block;
}

.aick-modal {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    border-radius: 0;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
    /* パネル本体だけクリックを受ける */
    pointer-events: auto;
    transform: translateX(0);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 入場アニメーション。
   PCは右から、スマホは下から出る（下は media query で差し替え）。 */
@keyframes aickSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes aickSlideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 会話履歴は Flexbox に高さを委ねる。
   従来の calc(95vh - 180px) はパネル化で破綻するため打ち消す。 */
.aick-chat-messages {
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
    /* パネル内のスクロールが背後のページに連鎖しないようにする。
       body の overflow:hidden をやめられるので iOS のスクロール位置飛びを回避できる。 */
    overscroll-behavior: contain;
}

/* 図が潰れて読めなくなるより、横スクロールさせる */
.mermaid-container .mermaid {
    min-width: 300px;
}

/* ---------- 折りたたみ / 復帰のボタン ---------- */

.aick-panel-collapse-btn {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}

.aick-panel-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 覗き見トグル（スマホのみ。入力欄の隣に置く）
   矢印だけだと何が起きるか分からないので、解説を出す向きにはラベルを添える。
   戻す向きは操作が自明になっているためアイコンのみ。 */
.aick-peek-toggle {
    display: none;
    flex: 0 0 auto;
    /* アイコンとラベルを縦に積む */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    width: 46px;
    height: 44px;
    padding: 0;
    border: 2px solid var(--aick-border);
    border-radius: 12px;
    background: var(--aick-bg-input);
    color: var(--aick-primary);
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, width 0.2s;
}

.aick-peek-icon::before {
    content: '▲';
    font-size: 11px;
}

.aick-peek-label {
    font-size: 9px;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

/* 覗き見中は「戻す」向きに反転し、ラベルを外して幅を詰める */
.aick-modal-overlay.peek .aick-peek-icon::before {
    content: '▼';
    font-size: 13px;
}

.aick-modal-overlay.peek .aick-peek-label {
    display: none;
}

.aick-modal-overlay.peek .aick-peek-toggle {
    width: 40px;
    background: var(--aick-primary);
    color: #fff;
    border-color: var(--aick-primary);
}

/* パネルが退避している間だけ出るつまみ */
.aick-panel-restore {
    display: none;
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 99998;
    width: 34px;
    height: 76px;
    padding: 0;
    border: none;
    border-radius: 10px 0 0 10px;
    background: var(--aick-gradient, linear-gradient(135deg, #0891b2, #0e7490));
    color: #fff;
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    box-shadow: -3px 0 14px rgba(0, 0, 0, 0.35);
}

body.aick-panel-collapsed .aick-panel-restore {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- PC: 右ドッキング＋幅可変 ---------- */

@media (min-width: 1025px) {
    /* 折りたたみ時は画面右外へ退避させる */
    .aick-modal-overlay.collapsed .aick-modal {
        transform: translateX(100%);
    }

    /* 覗き見トグルはスマホ専用 */
    .aick-peek-toggle {
        display: none;
    }

    /* 本文をパネル分だけ左に寄せる */
    body.aick-panel-open:not(.aick-panel-collapsed) {
        margin-right: var(--aick-panel-width);
    }

    /* Divi の固定ヘッダーは position:fixed のため body の余白を無視する。
       個別に右端を詰めないとパネルの下に潜り込む。 */
    body.aick-panel-open:not(.aick-panel-collapsed) #main-header,
    body.aick-panel-open:not(.aick-panel-collapsed) #top-header,
    body.aick-panel-open:not(.aick-panel-collapsed) .et_fixed_nav #main-header {
        left: 0;
        right: var(--aick-panel-width);
        width: auto;
    }

    /* 幅調整ハンドル（パネル左端） */
    .aick-panel-resizer {
        display: block;
        position: absolute;
        top: 0;
        left: -3px;
        width: 8px;
        height: 100%;
        cursor: col-resize;
        background: transparent;
        pointer-events: auto;
        z-index: 2;
    }

    .aick-panel-resizer::after {
        content: '';
        position: absolute;
        top: 0;
        left: 3px;
        width: 2px;
        height: 100%;
        background: transparent;
        transition: background 0.15s;
    }

    .aick-panel-resizer:hover::after,
    body.aick-panel-resizing .aick-panel-resizer::after {
        background: var(--aick-primary, #06b6d4);
    }

    /* ドラッグ中は本文の選択と遷移アニメを止める */
    body.aick-panel-resizing {
        cursor: col-resize;
    }

    body.aick-panel-resizing .aick-modal,
    body.aick-panel-resizing.aick-panel-open {
        transition: none;
    }
}

/* ---------- タブレット・スマホ: 全幅ドロワー ---------- */

@media (max-width: 1024px) {
    .aick-modal-overlay {
        width: 100%;
    }

    /* 画面が狭いので本文は押さない。覗き見状態にして解説を読む運用にする */
    body.aick-panel-open {
        margin-right: 0;
    }

    /* 幅可変とヘッダーの折りたたみボタンはPCのみ */
    .aick-panel-resizer,
    .aick-panel-collapse-btn {
        display: none;
    }

    /* 右端の復帰つまみもPC専用（スマホは入力欄のトグルで戻す） */
    body.aick-panel-collapsed .aick-panel-restore {
        display: none;
    }

    .aick-modal {
        border-radius: 0;
        /* 下から出る */
        animation-name: aickSlideUp;
        /* 基準を translateY に揃えておく。PC用の translateX(0) を
           そのまま使うと覗き見への補間が matrix 経由になり不安定なため。 */
        transform: translateY(0);
        /* 影も上向きに付け替える */
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
    }

    /* 入力欄の隣にトグルを出す */
    .aick-peek-toggle {
        display: flex;
    }

    /* トグルが1つ増える分、狭い端末で入力欄が潰れないよう余白を詰める */
    .aick-chat-input-area {
        gap: 8px;
    }

    /* ------- 覗き見状態 -------
       パネルを上へ逃がし、最下部の入力欄だけを画面上端に残す。
       translateY を % で書くことで、キーボード開閉でパネル高さ
       (--aick-vh) が変わっても残す量が自動で追従する。 */
    .aick-modal-overlay.peek .aick-modal {
        transform: translateY(calc(-100% + var(--aick-peek-height, 76px)));
    }

    /* 覗き見中は入力欄を最下部の要素にする必要があるため、
       その下にあるクレジット表示を隠す */
    .aick-modal-overlay.peek .aick-usage-info {
        display: none;
    }

    /* 覗き見中の入力欄は2行相当で打ち止め、以降は内部スクロールに任せる */
    .aick-modal-overlay.peek .aick-chat-input {
        max-height: 68px;
    }

    /* 覗き見中は画面上端に貼り付くので、下側の角を丸めて浮いて見せる */
    .aick-modal-overlay.peek .aick-chat-input-area {
        border-bottom: 1px solid var(--aick-border);
        border-radius: 0 0 14px 14px;
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    }
}

/* ---------- iOS のキーボードでビューポートが縮む問題 ---------- */

/* パネルの高さは3段のフォールバックで決める。
   1. --aick-vh : JS が visualViewport から実測した高さ。
      キーボード表示時に縮むのはこれだけ。dvh はアドレスバーの
      伸縮には追随するがキーボードでは変化しないため、
      入力欄がキーボードに隠れる問題はこれでしか直らない。
   2. 100dvh   : JS が動く前 / visualViewport 非対応時。
   3. 100vh    : dvh 非対応の古いブラウザ。 */
.aick-modal-overlay {
    height: 100vh;
    height: 100dvh;
    height: var(--aick-vh, 100dvh);
    bottom: auto;
}

/* セーフエリア（iPhone のホームバー）。
   従来はモーダルの margin-bottom で逃がしていたが、
   全高パネルでは最下部の要素に持たせる必要がある。 */
@media (max-width: 1024px) {
    .aick-usage-info {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}
