/* 選択モーダル専用：縦220px・横300pxに最適化 */
.unified-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.unified-modal-window {
    background: #fff;
    width: 300px;
    height: 210px; /* 縦210pxに厳密に合わせる */
    border: 3px solid #3b82f6; /* 全モーダル共通の枠線 */
    border-radius: 24px;      /* 指定の角丸 */
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 10px 40px rgba(59, 130, 246, 0.15); /* 微かな青い光彩 */
    position: relative;
    box-sizing: border-box;
    text-align: center;
    overflow: visible;
}

.unified-modal-title {
    font-size: 22px;
    font-weight: bold;
    color: #7c3aed;
    margin: 0 0 8px 0;
    /* マージンを削減 */
    text-align: center;
}

.unified-modal-description {
    font-size: 13px;
    line-height: 1.5;
    color: #4b5563;
    margin-bottom: 12px;
    text-align: left;
    flex-grow: 1;
    display: flex;
    align-items: center;
    /* 縦方向の中央寄せ */
}

/* 説明文内のテキストが適切にラップされるように修正 */
.unified-modal-description div {
    width: 100%;
}


.unified-modal-buttons {
    display: flex;
    flex-direction: row;
    /* 左右に並べる */
    gap: 8px;
    justify-content: center;
    margin-top: auto;
}



.unified-modal-btn {
    flex: 1;
    height: 44px;
    /* 高さを抑えて220pxに収める */
    border-radius: 12px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.unified-modal-btn.btn-gray {
    background: #70798c;
}

.unified-modal-btn.btn-blue {
    background: #2563eb;
}

.unified-modal-btn:hover {
    opacity: 0.9;
}

/* 共通パーツ：ハンバーガー・音声・最大化 */
.hamburger-btn, .voice-toggle-btn, .fullscreen-btn {
    position: fixed;
    width: 44px;
    height: 44px;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 11000;
    border: none;
    transition: all 0.2s ease;
}

.hamburger-btn { top: 20px; right: 20px; flex-direction: column; gap: 4px; }
.hamburger-btn span { width: 20px; height: 2.5px; background: #7c3aed; border-radius: 2px; }

.voice-toggle-btn { top: 75px; right: 20px; padding: 10px; }
.fullscreen-btn { top: 130px; right: 20px; padding: 10px; }

@media (max-width: 768px) {
    .hamburger-btn { top: 15px; right: 15px; }
    .voice-toggle-btn { top: 65px; right: 15px; }
    .fullscreen-btn { top: 115px; right: 15px; }
}

/* メニューオーバーレイ */
.menu-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 12500; /* floating buttons (11000) より手前にして隠す */
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease;
}
.menu-overlay.active { opacity: 1; visibility: visible; }
.menu-content {
    position: absolute;
    top: 0; right: -300px; width: 300px; height: 100%;
    background: white;
    border: 3px solid #3b82f6; /* モーダルと同じ罫線 */
    border-right: none;
    border-radius: 24px 0 0 24px; /* モーダルと同じ丸み */
    transition: right 0.3s ease;
    padding: 2.5rem 1.5rem;
    box-sizing: border-box;
    box-shadow: -5px 0 25px rgba(59, 130, 246, 0.15);
}
.menu-overlay.active .menu-content { right: 0; }

.menu-header { 
    display: flex; 
    justify-content: flex-start; 
    align-items: center; 
    margin-bottom: 2.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f3f4f6;
}
.menu-header h3 { color: #2563eb; margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: 0.05em; }

.menu-close-btn-round { 
    position: absolute; top: 15px; right: 15px;
    width: 36px; height: 36px; border-radius: 50%;
    background: #ef4444; color: white; border: none;
    display: flex; justify-content: center; align-items: center;
    font-size: 20px; cursor: pointer; transition: transform 0.2s;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.menu-close-btn-round:hover { transform: scale(1.1); }
.menu-list { display: flex; flex-direction: column; gap: 1rem; }
.menu-item {
    display: flex; align-items: center; gap: 1rem;
    padding: 0.75rem 1rem; border-radius: 12px;
    cursor: pointer; transition: background 0.2s;
}
.menu-item:hover { background: #f3f4f6; }
.menu-icon-circle {
    width: 32px; height: 32px; border-radius: 6px;
    background: transparent; display: flex; justify-content: center; align-items: center;
}
.menu-icon-circle img { width: 28px; height: 28px; opacity: 1; }
.menu-item span { color: #1e3a8a; font-weight: 600; font-size: 1.1rem; }
.menu-item.logout span { color: #db2777; }

/* 閉じるボタン（赤丸） */
.close-red-circle {
    position: absolute; top: -15px; right: -15px;
    width: 34px; height: 34px; border-radius: 50%;
    background: #ef4444; color: white;
    display: flex; justify-content: center; align-items: center;
    font-size: 24px; cursor: pointer;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4);
    z-index: 20000; line-height: 1; padding-bottom: 2px;
}

/* 汎用モーダル・履歴モーダルの追加スタイル */
.history-modal-overlay, .modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 12000;
    display: none; justify-content: center; align-items: center;
}

.history-modal-window, .modal-window {
    background: white; 
    border: 3px solid #3b82f6; /* 全モーダル共通 */
    border-radius: 24px;      /* 全モーダル共通 */
    position: relative; 
    overflow: visible;
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
}

.history-modal-window {
    width: 90%; max-width: 800px; height: 500px;
    display: flex; flex-direction: column;
}

.history-modal-header {
    padding: 1.5rem; border-bottom: 1px solid #f3f4f6; text-align: center;
}
.history-modal-header h3 { margin: 0; color: #1e3a8a; }

.history-modal-body { flex: 1; overflow-y: auto; padding: 1rem; }

.history-item {
    padding: 0.25rem 1rem;
    margin-bottom: 0.5rem;
    background: transparent;
}
.history-item-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem 0;
}
.history-item-header a {
    text-decoration: underline;
    text-underline-offset: 4px;
}
.history-item-header:hover a {
    color: #0056b3 !important;
}

/* 履歴モーダルのアコーディオンとログ表示 */
.history-accordion {
    max-height: 0; 
    overflow: hidden;
    transition: max-height 0.4s ease-out;
    background: transparent;
}
.history-accordion.open {
    max-height: 10000px; /* 十分な大きさを確保しつつスクロールは親で制御 */
    margin-top: 10px;
    margin-bottom: 25px;
}
.history-log-container {
    padding: 0.5rem 1rem; display: flex; flex-direction: column; gap: 0.75rem;
    background: transparent;
}
.history-log-bubble {
    padding: 0.6rem 1rem; font-size: 13.5px; line-height: 1.5;
    max-width: 90%; color: #333;
}
.log-ai { background: #ffd6f4; align-self: flex-start; }
.log-user { background: #f0f0f0; align-self: flex-end; text-align: left; }

.history-action-btns {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    gap: 1rem;
    justify-content: center;
    padding: 1rem;
    margin: 1rem 0;
    background: #f1f5f9 !important; /* 目立つ背景 */
    border: 2px solid #3b82f6 !important; /* 強調枠 */
    border-radius: 12px;
    z-index: 999 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
    position: relative !important;
}
.btn-continue, .btn-delete-log {
    padding: 0.8rem 1rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14.5px;
    font-weight: 800;
    transition: all 0.2s;
    min-width: 150px;
}
.btn-continue { 
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
    color: white !important; 
}
.btn-delete-log { 
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
    color: white !important; 
}
.btn-continue:hover { transform: scale(1.05); filter: brightness(1.2); }
.btn-delete-log:hover { transform: scale(1.05); filter: brightness(1.2); }
