* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background-color: #f7f7f8;
    height: 100vh;
    height: 100dvh; /* 動的ビューポート高さ（モバイル対応） */
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh; /* 動的ビューポート高さ（モバイル対応） */
    overflow: hidden; /* アプリ全体のスクロールを防ぐ */
    position: relative;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    background-color: transparent;
    border: none;
    color: #ececf1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.sidebar-toggle:hover {
    background-color: #2d2d30;
    border-radius: 8px;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: #171717;
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #4d4d4f;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.collapsed {
    transform: translateX(-260px);
}

.sidebar.collapsed ~ .sidebar-toggle {
    left: 20px;
}

.sidebar:not(.collapsed) ~ .sidebar-toggle {
    left: 20px;
}

.sidebar-header {
    padding: 20px;
    padding-left: 70px;
    border-bottom: 1px solid #4d4d4f;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #ececf1;
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    white-space: nowrap;
}

.app-title-text {
    white-space: nowrap;
    word-break: keep-all;
}

.app-version-badge {
    font-size: 11px;
    line-height: 1;
    color: #c7f9e6;
    background-color: #14532d;
    border: 1px solid #1f7a4c;
    border-radius: 999px;
    padding: 3px 8px;
    letter-spacing: 0.02em;
}

.new-chat-btn {
    width: 100%;
    padding: 10px;
    background-color: transparent;
    border: 1px solid #4d4d4f;
    color: #ececf1;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.new-chat-btn:hover {
    background-color: #2d2d30;
}

/* 検索ボックス */
.search-container {
    padding: 8px;
    border-bottom: 1px solid #4d4d4f;
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 8px 12px;
    background-color: #2d2d30;
    border: 1px solid #4d4d4f;
    border-radius: 6px;
    color: #ececf1;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input::placeholder {
    color: #888;
}

.search-input:focus {
    border-color: #565869;
}

.chat-history {
    flex: 1;
    padding: 8px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid #4d4d4f;
    flex-shrink: 0;
}

/* ログインヒント */
.login-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px;
    margin-bottom: 10px;
    background-color: rgba(16, 163, 127, 0.15);
    border: 1px solid rgba(16, 163, 127, 0.3);
    border-radius: 8px;
    font-size: 12px;
    color: #ececf1;
    position: relative;
    animation: hintFadeIn 0.3s ease;
}

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

.hint-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.hint-text {
    flex: 1;
    line-height: 1.4;
}

.close-hint {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: #8e8ea0;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    transition: color 0.2s;
}

.close-hint:hover {
    color: #ececf1;
}

.logout-btn {
    width: 100%;
    padding: 10px;
    background-color: transparent;
    border: 1px solid #4d4d4f;
    color: #ececf1;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.login-btn {
    width: 100%;
    padding: 10px;
    background-color: #10a37f;
    border: 1px solid #10a37f;
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    margin-bottom: 8px;
}

.login-btn:hover {
    background-color: #0d8c6c;
    border-color: #0d8c6c;
}

.logout-btn:hover {
    background-color: #c33;
    border-color: #c33;
}

.chat-history-item {
    padding: 12px;
    margin: 2px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative; /* For positioning delete button */
}

.chat-history-item:hover {
    background-color: #2d2d30;
}

.chat-history-item.active {
    background-color: #343541;
}

.chat-title {
    font-size: 14px;
    color: #ececf1;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-date {
    font-size: 12px;
    color: #8e8ea0;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    position: relative;
    transition: margin-left 0.3s ease;
    min-height: 0; /* flexboxの高さ制限を有効にする */
    overflow: hidden; /* 子要素のスクロールを有効にする */
}

.main-content.sidebar-collapsed {
    margin-left: -260px;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
    height: 100%;
    position: relative;
    min-height: 0; /* flexboxの高さ制限を有効にする */
    overflow: hidden; /* コンテナ自体のスクロールを防ぐ */
}

.compression-indicator {
    padding: 6px 16px;
    background: #f0f9ff;
    border-bottom: 1px solid #bae6fd;
    color: #0369a1;
    font-size: 12px;
    text-align: center;
    flex-shrink: 0;
}

.compression-indicator .compression-icon {
    margin-right: 4px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    min-height: 0; /* flexboxの高さ制限を有効にする */
    -webkit-overflow-scrolling: touch; /* iOS用のスムーズスクロール */
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

.welcome-message h3 {
    font-size: 24px;
    margin-bottom: 12px;
    color: #374151;
}

.message {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
}

.user-message {
    align-items: flex-end;
}

.ai-message {
    align-items: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.user-message .message-content {
    background-color: #007aff;
    color: white;
	white-space: pre-wrap;
}

.ai-message .message-content {
    background-color: #f1f1f1;
    color: #374151;
	white-space: pre-wrap;
}

/* AIメッセージのコンテナ（コピーボタン用） */
.ai-message-wrapper {
    position: relative;
    max-width: 70%;
}

.ai-message-wrapper .message-content {
    max-width: 100%;
}

.message-copy-btn {
    position: absolute;
    bottom: -24px;
    right: 0;
    padding: 4px 8px;
    font-size: 12px;
    background-color: #e5e7eb;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #6b7280;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

.ai-message-wrapper:hover .message-copy-btn,
.message-copy-btn:focus {
    opacity: 1;
}

.message-copy-btn:hover {
    background-color: #d1d5db;
    color: #374151;
}

.message-copy-btn.copied {
    background-color: #10b981;
    color: white;
}

.csv-download-btn {
    position: absolute;
    bottom: -24px;
    right: 60px;
    padding: 4px 8px;
    font-size: 12px;
    background-color: #d1fae5;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #065f46;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

.ai-message-wrapper:hover .csv-download-btn {
    opacity: 1;
}

.csv-download-btn:hover {
    background-color: #a7f3d0;
    color: #064e3b;
}

.word-download-btn {
    position: absolute;
    bottom: -24px;
    right: 170px;
    padding: 4px 8px;
    font-size: 12px;
    background-color: #dbeafe;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: #1e40af;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

.ai-message-wrapper:hover .word-download-btn {
    opacity: 1;
}

.word-download-btn:hover {
    background-color: #bfdbfe;
    color: #1e3a8a;
}

/* Typing Indicator Animation */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: #999;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Container */
.input-container {
    padding: 20px;
    background-color: white;
    border-top: 1px solid #e5e7eb;
}

/* Web検索トグル */
.input-options {
    max-width: 800px;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.web-search-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #6b7280;
    user-select: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.web-search-toggle:hover {
    background-color: #f3f4f6;
}

.web-search-toggle input[type="checkbox"] {
    display: none;
}

.toggle-icon {
    font-size: 16px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.web-search-toggle input[type="checkbox"]:checked ~ .toggle-icon {
    opacity: 1;
}

.toggle-label {
    color: #9ca3af;
    transition: color 0.2s;
}

.web-search-toggle input[type="checkbox"]:checked ~ .toggle-label {
    color: #10a37f;
    font-weight: 500;
}

.response-length-control {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6b7280;
}

.response-length-control label {
    white-space: nowrap;
}

#response-length-select {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: white;
    color: #374151;
    font-size: 13px;
    padding: 4px 8px;
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: flex-end;
    background-color: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 8px;
}

#user-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    line-height: 1.4;
    padding: 8px 12px;
    resize: none;
    min-height: 20px;
    max-height: 120px;
    font-family: inherit;
}

.voice-btn {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.2s, background-color 0.2s;
    flex-shrink: 0;
    border-radius: 8px;
    padding: 0;
}

.voice-btn:hover {
    color: #007aff;
}

.voice-btn.active {
    color: #fff;
    background-color: #ef4444;
    animation: voice-pulse-btn 1.5s ease-in-out infinite;
}

@keyframes voice-pulse-btn {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.send-btn {
    background-color: #007aff;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: background-color 0.2s;
    margin-left: 8px;
}

.send-btn:hover {
    background-color: #0056b3;
}

.send-btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.attach-btn {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.2s;
    flex-shrink: 0;
}

.attach-btn:hover {
    color: #007aff;
}

.attachment-preview {
    max-width: 800px;
    margin: 0 auto 6px auto;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 4px;
}

.attachment-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f0f4ff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
    color: #374151;
    max-width: 200px;
}

.attachment-chip img {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
}

.attachment-chip .remove-attachment {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
}

.attachment-chip .remove-attachment:hover {
    color: #ef4444;
}

.attachment-chip .att-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100px;
}

.attachment-chip.uploading {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #78350f;
}

.attachment-chip .att-uploading {
    font-size: 11px;
    color: #b45309;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.attachment-chip .att-uploading::before {
    content: '';
    width: 10px;
    height: 10px;
    border: 2px solid #b45309;
    border-top-color: transparent;
    border-radius: 50%;
    animation: att-spinner 0.8s linear infinite;
    display: inline-block;
}

@keyframes att-spinner {
    to { transform: rotate(360deg); }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
        max-width: 85%;
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* サイドバーが開いているときのオーバーレイ */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }
    
    .main-content.sidebar-collapsed {
        margin-left: 0;
    }
    
    .sidebar-toggle {
        display: flex;
        position: fixed;
        top: 10px;
        left: 10px;
        z-index: 999;
        background-color: #171717;
        border-radius: 8px;
        width: 44px;
        height: 44px;
    }
    
    .sidebar-toggle:hover {
        background-color: #2d2d30;
    }
    
    /* サイドバーヘッダーの調整 */
    .sidebar-header {
        padding-left: 60px;
    }
    
    .code-panel.visible {
        width: 100%;
        position: absolute;
        top: 0;
        right: 0;
        z-index: 999;
    }
    
    .message-content {
        max-width: 95%;
    }
    
    .ai-message-wrapper {
        max-width: 95%;
    }
    
    .ai-message-wrapper .message-content {
        max-width: 100%;
    }
    
    /* 入力エリアの調整 */
    .input-container {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        flex-shrink: 0;
    }
    
    .input-wrapper {
        padding: 6px;
    }
    
    /* チャットコンテナをビューポートに収める */
    .chat-container {
        height: 100%;
        max-height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    /* パネルヘッダーの調整 */
    .panel-header {
        padding: 16px;
        padding-top: 60px; /* トグルボタンのスペース */
    }
    
    .panel-header h2 {
        font-size: 20px;
    }
    
    /* ウェルカムメッセージの調整 */
    .welcome-message {
        padding: 40px 16px;
        padding-top: 60px; /* トグルボタンのスペース */
    }
    
    .welcome-message h3 {
        font-size: 20px;
    }
    
    /* チャットメッセージエリアの調整 */
    .chat-messages {
        padding: 16px;
        padding-top: 60px; /* トグルボタンのスペース */
    }
    
    /* カスタムモードリストの調整 */
    .custom-modes-list {
        grid-template-columns: 1fr;
    }
    
    /* 返信生成・マーケティングコンテナの調整 */
    .reply-gen-container,
    .marketing-container,
    .custom-mode-container {
        padding: 16px;
    }
    
    /* モーダルの調整 */
    .modal-content {
        width: 95%;
        max-height: 85vh;
    }
}

/* Delete Chat Button */
.delete-chat-button {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #8e8ea0;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    display: none; /* Initially hidden */
    transition: color 0.2s;
}

.chat-history-item:hover .delete-chat-button {
    display: block; /* Show on hover */
}

.delete-chat-button:hover {
    color: #ececf1; /* Brighter color on hover */
}


/* Source Code Block Styling */
.message-code-block {
    background-color: #e0e0e0; /* 薄いグレーの背景色 */
    color: #333; /* 暗めの文字色 */
    font-family: 'Consolas', 'Courier New', monospace; /* 等幅フォント */
    padding: 15px; /* 内側の余白 */
    border: 1px solid #ccc; /* 枠線 */
    border-radius: 6px; /* 角丸 */
    overflow: auto; /* スクロールバーを表示 */
    max-height: 400px; /* 最大の高さ */
    white-space: pre-wrap; /* 長い行の折り返し */
    word-break: break-all; /* 単語の途中改行 */
    margin-top: 10px; /* 上のマージン */
    margin-bottom: 10px; /* 下のマージン */
    width: 100%; /* メッセージの幅全体を占める */
}

/* AIメッセージ内のコードブロックのマージン調整 */
.ai-message .message-code-block {
    margin-left: 0; /* AIメッセージの左端に合わせる */
    margin-right: 0; /* AIメッセージの右端に合わせる */
    max-width: 100%; /* AIメッセージのコンテンツ幅に合わせる */
}

/* Code block container and copy button */
.code-block-container {
    position: relative;
    margin-bottom: 1em;
    background-color: #f5f5f5; /* Highlight.jsのデフォルトスタイルに合わせるか、テーマに合わせる */
    border-radius: 4px;
}

.copy-code-btn {
    position: absolute;
    top: 8px; /* 少し内側に配置 */
    right: 8px; /* 少し内側に配置 */
    padding: 4px 10px; /* 少し大きめに */
    font-size: 0.85em; /* 少し大きめに */
    background-color: #e0e0e0; /* ボタンの色を調整 */
    border: 1px solid #ccc;
    border-radius: 4px; /* 角丸を調整 */
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    color: #333;
    z-index: 10; /* 他の要素より手前に表示 */
}

.copy-code-btn:hover {
    background-color: #d0d0d0;
    color: #000;
}

.copy-code-btn:active {
    background-color: #c0c0c0;
}

/* Highlight.js の <pre><code> スタイル調整 */
.code-block-container pre {
    margin: 0;
    padding: 1em; /* Highlight.jsのデフォルトパディングと合わせる */
    overflow-x: auto;
    border-radius: 4px; /* コンテナと合わせる */
}

.code-block-container pre code.hljs {
    /* 必要に応じてHighlight.jsのスタイルを上書き */
    padding: 0; /* preにパディングがあるのでcodeは0に */
    background: none; /* 背景はpreで設定 */
}

/* Feature Menu */
.feature-menu {
    padding: 12px 8px;
    border-bottom: 1px solid #4d4d4f;
    flex-shrink: 0;
}

.feature-btn {
    width: 100%;
    padding: 10px 12px;
    background-color: transparent;
    border: none;
    color: #ececf1;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    margin-bottom: 4px;
    transition: background-color 0.2s;
}

.feature-btn:hover {
    background-color: #2d2d30;
}

.feature-btn.active {
    background-color: #007aff;
    color: white;
}

/* Feature Panels */
.feature-panel {
    display: none;
    width: 100%;
    height: 100%; /* 親要素(.main-content)の高さに合わせる */
    overflow: hidden; /* パネル自体のスクロールを防ぐ */
}

.feature-panel.active {
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    background-color: white;
}

.panel-header h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: #374151;
}

.panel-header p {
    font-size: 14px;
    color: #6b7280;
}

/* Reply Generation Panel */
.reply-gen-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: #007aff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.primary-btn {
    padding: 12px 24px;
    background-color: #007aff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: #0056b3;
}

.primary-btn:disabled {
    background-color: #9ca3af;
    cursor: not-allowed;
}

.secondary-btn {
    padding: 12px 24px;
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 12px;
}

.secondary-btn:hover {
    background-color: #e5e7eb;
}

.output-box {
    margin-top: 20px;
    padding: 20px;
    background-color: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 8px;
}

.output-box label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

#generated-reply-text,
#marketing-text {
    padding: 16px;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    margin-bottom: 12px;
    white-space: pre-wrap;
    line-height: 1.6;
    color: #374151;
}

/* Marketing Panel */
.marketing-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* Custom Mode Panel */
.custom-mode-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.custom-modes-list {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.custom-mode-card {
    padding: 20px;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.custom-mode-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-color: #007aff;
}

.custom-mode-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: #374151;
}

.custom-mode-card p {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 12px;
}

.custom-mode-actions {
    display: flex;
    gap: 8px;
}

.custom-mode-actions button {
    flex: 1;
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.use-mode-btn {
    background-color: #007aff;
    color: white;
}

.use-mode-btn:hover {
    background-color: #0056b3;
}

.edit-mode-btn {
    background-color: #f3f4f6;
    color: #374151;
}

.edit-mode-btn:hover {
    background-color: #e5e7eb;
}

.delete-mode-btn {
    background-color: #fee2e2;
    color: #dc2626;
}

.delete-mode-btn:hover {
    background-color: #fecaca;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 20px;
    color: #374151;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: #374151;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Custom Mode Item */
.custom-mode-item {
    padding: 16px;
    background-color: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mode-info h4 {
    font-size: 16px;
    margin-bottom: 4px;
    color: #374151;
}

.mode-info p {
    font-size: 14px;
    color: #6b7280;
}

.mode-actions {
    display: flex;
    gap: 8px;
}

.mode-actions button {
    padding: 8px 16px;
    font-size: 13px;
}

/* ========== イラスト生成パネル ========== */
.illust-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.illust-step {
    animation: fadeIn 0.2s ease;
}

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

.illust-rate-info {
    margin-bottom: 16px;
    padding: 10px 14px;
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.illust-step2-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.illust-step2-actions .secondary-btn {
    margin-top: 0;
}

.illust-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 60px 20px;
    text-align: center;
    color: #6b7280;
    font-size: 15px;
    line-height: 1.7;
}

.illust-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #007aff;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

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

.illust-image-box {
    text-align: center;
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: hidden;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
}

.illust-image-box img {
    max-width: 100%;
    max-height: 70vh;
    display: block;
    margin: 0 auto;
    border-radius: 12px;
}

.illust-result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.illust-result-actions .secondary-btn {
    margin-top: 0;
}

/* ========== イラスト機能 新UI ========== */

/* 縦横比セレクター */
.illust-aspect-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.illust-aspect-label {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    display: block;
}

.aspect-btn {
    padding: 10px 16px;
    border: 2px solid #d1d5db;
    border-radius: 10px;
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #374151;
    line-height: 1.3;
    text-align: center;
    min-width: 80px;
}

.aspect-btn:hover {
    border-color: #007aff;
    background: #eff6ff;
}

.aspect-btn.selected {
    border-color: #007aff;
    background: #007aff;
    color: #fff;
}

/* 参照画像アップロード */
.illust-ref-section {
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 2px dashed #d1d5db;
    border-radius: 10px;
    background: #fafafa;
    transition: border-color 0.15s;
}

.illust-ref-section.has-image {
    border-color: #10b981;
    background: #f0fdf4;
}

.illust-ref-label {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    display: block;
}

.illust-ref-desc {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 10px;
}

.illust-ref-upload-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.illust-ref-upload-btn {
    padding: 8px 16px;
    border: 1px solid #007aff;
    border-radius: 8px;
    background: #fff;
    color: #007aff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.illust-ref-upload-btn:hover {
    background: #eff6ff;
}

.illust-ref-clear-btn {
    padding: 8px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    color: #6b7280;
    font-size: 13px;
    cursor: pointer;
    display: none;
}

.illust-ref-preview {
    display: none;
    margin-top: 10px;
}

.illust-ref-preview img {
    max-height: 120px;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.illust-ref-name {
    font-size: 13px;
    color: #059669;
    margin-top: 4px;
}

/* ミニチャット（パネル内編集チャット） */
.illust-mini-chat {
    margin-top: 20px;
    border-top: 1px solid #e5e7eb;
    padding-top: 18px;
}

.illust-mini-chat-title {
    font-size: 16px;
    font-weight: 700;
    color: #374151;
    margin-bottom: 6px;
}

.illust-mini-chat-desc {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 12px;
}

.illust-mini-chat-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.illust-mini-chat-input {
    flex: 1;
    padding: 12px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    font-size: 15px;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    font-family: inherit;
    transition: border-color 0.15s;
}

.illust-mini-chat-input:focus {
    outline: none;
    border-color: #007aff;
}

.illust-mini-chat-send {
    padding: 12px 18px;
    background: #007aff;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.illust-mini-chat-send:hover {
    background: #0062cc;
}

.illust-mini-chat-send:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* チャットに追加ボタン */
.illust-add-to-chat-btn {
    padding: 12px 20px;
    background: #10b981;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    margin-top: 0;
}

.illust-add-to-chat-btn:hover {
    background: #059669;
}

/* チャット内の生成済みイラスト表示 */
.illust-chat-image-wrap {
    margin: 4px 0;
}

.illust-chat-image-wrap img {
    max-width: 320px;
    max-height: 320px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    display: block;
}

.illust-chat-caption {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

/* 履歴ボタン（パネルヘッダー右上） */
.illust-history-header-btn {
    padding: 7px 14px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.illust-history-header-btn:hover {
    background: #e5e7eb;
}

/* 履歴グリッド */
.illust-history-header {
    margin-bottom: 4px;
}
.illust-history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}
.illust-history-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.illust-history-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.illust-history-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}
.illust-history-date {
    font-size: 10px;
    color: #9ca3af;
    padding: 4px 6px;
    background: #fff;
    line-height: 1.4;
}
.illust-history-item-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: none;
}
.illust-history-item:hover .illust-history-item-actions {
    display: flex;
}
.illust-history-delete-btn {
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.illust-history-delete-btn:hover {
    background: #ef4444;
}
.illust-history-empty {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 14px;
}

/* 拡大ビューモーダル */
.illust-viewer-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.illust-viewer-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.75);
}
.illust-viewer-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.illust-viewer-content img {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: 8px;
    display: block;
}
.illust-viewer-close {
    position: absolute;
    top: -36px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}
.illust-viewer-prompt {
    color: #e5e7eb;
    font-size: 12px;
    max-width: 90vw;
    text-align: center;
    word-break: break-word;
}

/* ========== Voice Mode ========== */
.voice-mode-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 8px;
}

.voice-mode-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.voice-visualizer {
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-pulse {
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, #007aff 0%, #0056b3 100%);
    border-radius: 50%;
    animation: voice-pulse-ring 2s ease-in-out infinite;
}

@keyframes voice-pulse-ring {
    0% { transform: scale(0.8); box-shadow: 0 0 0 0 rgba(0, 122, 255, 0.5); }
    50% { transform: scale(1.1); box-shadow: 0 0 0 20px rgba(0, 122, 255, 0); }
    100% { transform: scale(0.8); box-shadow: 0 0 0 0 rgba(0, 122, 255, 0); }
}

.voice-mode-status {
    color: #fff;
    font-size: 18px;
    font-weight: 500;
    text-align: center;
}

.voice-mode-stop-btn {
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 12px 32px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.voice-mode-stop-btn:hover {
    background: #dc2626;
}
