/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

/* ログインページ */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.login-form h1 {
    text-align: center;
    color: #333;
    margin-bottom: 0.5rem;
}

.login-form h2 {
    text-align: center;
    color: #666;
    margin-bottom: 2rem;
    font-weight: normal;
}

/* チャットコンテナ */
.chat-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* サイドバー */
.sidebar {
    width: 300px;
    background-color: #4a154b;
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ddd;
}

.sidebar-header {
    padding: 1rem;
    background-color: #3f0e40;
    border-bottom: 1px solid #5c2b5e;
}

.sidebar-header h2 {
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.admin-badge {
    background-color: #e01e5a;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    align-self: flex-start;
}

.user-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.debug-btn {
    background-color: #36c5f0;
    color: white;
    border: none;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.debug-btn:hover {
    background-color: #2a9fc7;
}

.logout-btn {
    color: #b39bc1;
    text-decoration: none;
    font-size: 0.9rem;
}

.logout-btn:hover {
    color: white;
}

.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.channel-item {
    display: block;
    padding: 0.5rem 1rem;
    color: #b39bc1;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.channel-item:hover {
    background-color: #5c2b5e;
    color: white;
}

.channel-item.active {
    background-color: #1264a3;
    color: white;
    border-left-color: #007bb6;
}

.channel-name {
    font-weight: 500;
}

.admin-only-badge {
    background-color: #e01e5a;
    padding: 0.1rem 0.3rem;
    border-radius: 8px;
    font-size: 0.7rem;
    margin-left: 0.5rem;
}

.admin-link {
    display: block;
    padding: 0.5rem 1rem;
    color: #ffd700;
    text-decoration: none;
    margin-top: 1rem;
    border-top: 1px solid #5c2b5e;
    font-weight: 500;
}

.admin-link:hover {
    background-color: #5c2b5e;
}

/* メインコンテンツ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: white;
    overflow-y: auto;
    height: 100vh;
}

.channel-header {
    padding: 1rem;
    border-bottom: 1px solid #ddd;
    background-color: white;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
}

.channel-header h3 {
    margin: 0;
    color: #333;
}

.channel-header p {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
}

/* メッセージコンテナ */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background-color: white;
}

/* 日付区切り */
.date-divider {
    display: flex;
    align-items: center;
    margin: 1rem 0;
    padding: 0 1rem;
}

.date-divider::before,
.date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background-color: #e1e5e9;
}

.date-text {
    padding: 0 1rem;
    font-size: 0.9rem;
    color: #666;
    background-color: white;
    font-weight: 500;
}

/* メッセージスタイル */
.message {
    display: flex;
    padding: 0.5rem 1rem;
    position: relative;
    border: none;
    background: none;
    box-shadow: none;
    margin: 0;
    border-radius: 0;
}

.message:hover {
    background-color: #f8f9fa;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    /* background-color は動的に設定 */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.avatar-initial {
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    flex-wrap: wrap;
}

.message-author {
    font-weight: bold;
    color: #1d1c1d;
    font-size: 0.95rem;
}

.message-time {
    color: #616061;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.message-actions {
    margin-left: auto;
    display: none;
    gap: 0.25rem;
}

.message:hover .message-actions {
    display: flex;
}

.edit-btn,
.delete-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    opacity: 0.7;
}

.edit-btn:hover {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    opacity: 1;
}

.delete-btn:hover {
    background-color: #dc3545;
    color: white;
    border-color: #dc3545;
    opacity: 1;
}

.message-content {
    line-height: 1.4;
    color: #1d1c1d;
    word-wrap: break-word;
}

.message-file {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #007bff;
}

.message-file a {
    color: #007bff;
    text-decoration: none;
}

.message-file a:hover {
    text-decoration: underline;
}

/* メッセージ入力 */
.message-input-container {
    padding: 1rem;
    background-color: white;
    border-top: 1px solid #ddd;
}

.message-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.input-row textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.75rem;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}

.send-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

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

.input-options {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.file-upload,
.scheduled-post-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-upload input[type="file"] {
    display: none;
}

.scheduled-post-container {
    position: relative;
}

.schedule-toggle {
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    color: #616061;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s;
}

.schedule-toggle:hover {
    background-color: #f5f5f5;
    color: #1d1c1d;
}

.schedule-toggle .schedule-icon {
    font-size: 0.8rem;
}

.schedule-toggle .schedule-text {
    font-size: 0.75rem;
}

.scheduled-post {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 240px;
    max-width: 300px;
}

.scheduled-post input[type="datetime-local"] {
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 0.5rem;
    font-size: 0.9rem;
    background-color: #fafafa;
    color: #616061;
    margin-bottom: 0.5rem;
    width: 100%;
    box-sizing: border-box;
}

.scheduled-post label {
    font-size: 0.85rem;
    color: #616061;
    font-weight: 400;
    display: block;
}

.no-permission-message,
.no-channel-message {
    text-align: center;
    color: #666;
    padding: 2rem;
    font-style: italic;
}

/* フォームスタイル */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* ボタンスタイル */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

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

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* チェックボックス用のスタイル */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: #666;
}

.checkbox-label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

/* ログアウトドロップダウン */
.logout-dropdown {
    position: relative;
    display: inline-block;
}

.logout-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: white;
    min-width: 250px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    border: 1px solid #ddd;
    z-index: 1000;
    margin-top: 5px;
}

.logout-dropdown-menu.show {
    display: block;
}

.logout-option {
    display: block;
    padding: 10px 15px;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

.logout-option:last-child {
    border-bottom: none;
}

.logout-option:hover {
    background-color: #f8f9fa;
}

.dropdown-toggle {
    background: none;
    border: none;
    color: #007bff;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
}

/* 管理画面 */
.admin-page {
    background-color: #f8f9fa;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.admin-header h1 {
    color: #333;
}

.back-btn {
    background-color: #6c757d;
    color: white;
    padding: 0.5rem 1rem;
    text-decoration: none;
    border-radius: 6px;
}

.back-btn:hover {
    background-color: #545b62;
}

.admin-tabs {
    display: flex;
    margin-bottom: 2rem;
    border-bottom: 1px solid #ddd;
}

.tab-btn {
    background: none;
    border: none;
    padding: 1rem 2rem;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: #007bff;
    border-bottom-color: #007bff;
}

.tab-btn:hover {
    color: #333;
}

.section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.section h2 {
    margin-bottom: 1.5rem;
    color: #333;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    align-items: end;
}

.table-container {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.admin-table th,
.admin-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.admin-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.admin-table tr:hover {
    background-color: #f8f9fa;
}

/* 予約投稿テーブルの列幅調整 */
#scheduled-tab .admin-table th:nth-child(1),
#scheduled-tab .admin-table td:nth-child(1) {
    /* チャンネル */
    width: 15%;
    min-width: 80px;
    max-width: 120px;
}

#scheduled-tab .admin-table th:nth-child(2),
#scheduled-tab .admin-table td:nth-child(2) {
    /* 投稿者 */
    width: 15%;
    min-width: 80px;
    max-width: 120px;
}

#scheduled-tab .admin-table th:nth-child(3),
#scheduled-tab .admin-table td:nth-child(3) {
    /* 内容 */
    width: 40%;
    max-width: 250px;
}

#scheduled-tab .admin-table th:nth-child(4),
#scheduled-tab .admin-table td:nth-child(4) {
    /* 予約日時 */
    width: 18%;
    min-width: 120px;
    max-width: 150px;
}

#scheduled-tab .admin-table th:nth-child(5),
#scheduled-tab .admin-table td:nth-child(5) {
    /* 操作 */
    width: 12%;
    min-width: 100px;
    max-width: 120px;
}

#scheduled-tab .admin-table {
    table-layout: fixed;
    width: 100%;
}

#scheduled-tab .message-preview {
    max-width: 250px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* メッセージスタイル */
.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #c3e6cb;
    margin-bottom: 1rem;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 1rem;
    border-radius: 6px;
    border: 1px solid #f5c6cb;
    margin-bottom: 1rem;
}

/* 予約投稿関連スタイル（管理者のみ） */
.admin-badge+.user-actions .scheduled-link,
.scheduled-link {
    display: block;
    padding: 0.5rem 1rem;
    color: #b39bc1;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
    border-top: 1px solid #5c2b5e;
}

.admin-badge+.user-actions .scheduled-link:hover,
.scheduled-link:hover {
    background-color: #5c2b5e;
    color: white;
}

.admin-badge+.user-actions .scheduled-link.active,
.scheduled-link.active {
    background-color: #1264a3;
    color: white;
    border-left-color: #007bb6;
}

.scheduled-messages-container {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.no-scheduled-messages {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.scheduled-message-item {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.scheduled-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.scheduled-channel {
    font-weight: bold;
    color: #4a154b;
    font-size: 0.9rem;
}

.scheduled-date {
    color: #e01e5a;
    font-size: 0.85rem;
    font-weight: 500;
}

.scheduled-message-content {
    margin-bottom: 1rem;
    line-height: 1.5;
    color: #333;
}

.scheduled-file {
    background-color: #f8f9fa;
    padding: 0.5rem;
    border-radius: 4px;
    border-left: 3px solid #007bff;
    margin-top: 0.5rem;
    color: #007bff;
}

.scheduled-message-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.message-preview {
    max-height: 100px;
    overflow: hidden;
    line-height: 1.4;
}

/* モーダルスタイル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

.modal-header h3 {
    margin: 0;
    color: #333;
}

.modal .close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
}

.modal .close-btn:hover {
    color: #333;
}

.modal .form-group {
    margin: 1rem 1.5rem;
}

.modal-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* 通知設定関連スタイル */
.user-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
    }

    .sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1000;
    }

    .sidebar.show {
        display: flex;
    }

    .mobile-menu-btn {
        display: block !important;
    }

    .channel-header {
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .admin-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .admin-tabs {
        flex-direction: column;
    }

    .input-options {
        flex-direction: column;
        align-items: flex-start;
    }

    .message-actions {
        margin-left: 0;
        margin-top: 0.5rem;
        display: flex !important;
    }

    .message {
        padding: 0.75rem 1rem;
    }

    .message-avatar {
        width: 36px;
        height: 36px;
        margin-right: 0.5rem;
    }

    .avatar-initial {
        font-size: 1rem;
    }

    .scheduled-message-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .scheduled-message-actions {
        justify-content: flex-start;
    }

    .modal {
        width: 95%;
        margin: 1rem;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions .btn {
        width: 100%;
    }

    .user-actions {
        flex-direction: row;
        gap: 0.3rem;
    }
}

/* モバイルメニューオーバーレイ */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.mobile-menu {
    background-color: white;
    width: 80%;
    max-width: 300px;
    height: 100%;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.mobile-menu-header {
    padding: 1rem;
    background-color: #4a154b;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.mobile-channel-list {
    padding: 1rem 0;
}

.mobile-channel-item {
    display: block;
    padding: 1rem;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #eee;
}

.mobile-channel-item:hover {
    background-color: #f8f9fa;
}

@media (max-width: 768px) {
    .mobile-menu-overlay.show {
        display: block;
    }
}

/* スクロールバーのスタイル */
.messages-container::-webkit-scrollbar,
.channel-list::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track,
.channel-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-container::-webkit-scrollbar-thumb,
.channel-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover,
.channel-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* スレッド機能スタイル */
.message {
    position: relative;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-thread {
    margin-top: 0.5rem;
    padding-left: 20px;
    /* 左側に表示するため調整 */
}

.thread-summary {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.thread-toggle {
    background: none;
    border: none;
    color: #1264a3;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.25rem 0;
    border-radius: 4px;
    transition: all 0.2s;
    text-decoration: none;
}

.thread-toggle:hover {
    text-decoration: underline;
    color: #0b4c8c;
}

.message-actions {
    position: absolute;
    right: 1rem;
    top: 0.5rem;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 0.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.reply-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.reply-btn:hover {
    background-color: #f8f9fa;
    color: #1264a3;
}

.edit-btn,
.delete-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    transition: all 0.2s;
    margin-left: 0.25rem;
}

.edit-btn:hover {
    background-color: #f8f9fa;
    color: #1264a3;
}

.delete-btn:hover {
    background-color: #f8f9fa;
    color: #dc3545;
}

/* スレッドサイドパネル */
.thread-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    border-left: 1px solid #e0e0e0;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.thread-panel.open {
    right: 0;
}

.thread-panel-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.thread-panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.thread-panel-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.thread-panel-close:hover {
    background-color: #e9ecef;
}

.thread-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 120px);
    /* ヘッダーと入力エリアを除いた高さ */
}

.thread-original-message {
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.thread-replies {
    flex: 0 0 auto;
    min-height: auto;
}

.thread-reply {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
}

.thread-reply:last-child {
    margin-bottom: 0;
}

.thread-reply .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.thread-reply .message-body {
    flex: 1;
    min-width: 0;
}

.thread-reply .message-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.25rem;
}

.thread-reply .message-author {
    font-weight: 600;
    color: #1d1c1d;
    font-size: 0.9rem;
}

.thread-reply .message-time {
    color: #616061;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.thread-reply .message-content {
    font-size: 0.9rem;
    color: #1d1c1d;
    line-height: 1.46;
    word-wrap: break-word;
}

.thread-reply .message-file {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.thread-reply .message-file a {
    color: #1264a3;
    text-decoration: none;
    font-size: 0.9rem;
}

.thread-reply .message-file a:hover {
    text-decoration: underline;
}

.thread-input-container {
    padding: 1rem;
    border-top: 1px solid #e0e0e0;
    background: white;
    flex-shrink: 0;
    min-height: 120px;
}

.thread-input-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.thread-input-form textarea {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0.75rem;
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
    font-size: 0.9rem;
}

.thread-input-form textarea:focus {
    outline: none;
    border-color: #1264a3;
    box-shadow: 0 0 0 2px rgba(18, 100, 163, 0.1);
}

.thread-input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.thread-file-upload {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.thread-file-upload input[type="file"] {
    display: none;
}

.thread-file-upload label {
    color: #6c757d;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.thread-file-upload label:hover {
    background-color: #f8f9fa;
    color: #1264a3;
}

.thread-send-btn {
    background: #1264a3;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.thread-send-btn:hover {
    background: #0b4c8c;
}

.thread-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.thread-messages {
    display: none;
    /* 従来の表示を無効化 */
}

/* スレッド予約投稿オプション */
.thread-scheduled-container {
    margin-bottom: 0.75rem;
}

.thread-schedule-toggle {
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    color: #616061;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.2s;
}

.thread-schedule-toggle:hover {
    background-color: #f5f5f5;
    color: #1d1c1d;
}

.schedule-icon {
    font-size: 0.8rem;
}

.schedule-text {
    font-size: 0.75rem;
}

.thread-scheduled-options {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: transparent;
    border: none;
    border-radius: 0;
}

.thread-scheduled-options label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 400;
    color: #616061;
    font-size: 0.8rem;
}

.thread-scheduled-options input[type="datetime-local"] {
    width: 100%;
    padding: 0.4rem;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.8rem;
    background-color: #fafafa;
    color: #616061;
    transition: border-color 0.2s, background-color 0.2s;
}

.thread-scheduled-options input[type="datetime-local"]:focus {
    outline: none;
    border-color: #ccc;
    background-color: white;
    box-shadow: none;
}

.thread-scheduled-options input[type="datetime-local"]:hover {
    border-color: #d0d0d0;
    background-color: white;
}

/* スレッド返信の予約投稿表示 */
.scheduled-thread-info {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background-color: #f1f3f4;
    border-radius: 4px;
    border-left: 3px solid #1264a3;
}

.thread-indicator {
    color: #1264a3;
    font-weight: bold;
    margin-right: 0.5rem;
}

.thread-parent-author {
    font-weight: 500;
    color: #1d1c1d;
    margin-right: 0.25rem;
}

.thread-parent-preview {
    color: #616061;
    font-size: 0.9rem;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .thread-panel {
        width: 100%;
        right: -100%;
    }

    .message-thread {
        padding-left: 10px;
    }

    .message-actions {
        position: static;
        opacity: 1;
        margin-top: 0.5rem;
        margin-left: 55px;
    }
}

/* 予約投稿のモバイル対応 */
@media (max-width: 768px) {
    .scheduled-post {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        right: auto;
        margin-top: 0;
        max-width: 90vw;
        width: 280px;
        z-index: 1000;
    }

    .scheduled-post::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: -1;
    }
}

/* 通知設定画面 */
.notification-settings {
    padding: 1.5rem;
    max-width: 800px;
    height: auto;
    overflow-y: auto;
}

.notification-status {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #28a745;
}

.notification-status h3 {
    margin-bottom: 0.75rem;
    color: #333;
}

.status-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    font-weight: 500;
}

.notification-info {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #e3f2fd;
    border-radius: 8px;
    border-left: 4px solid #2196f3;
}

.notification-info h3 {
    margin-bottom: 0.75rem;
    color: #1976d2;
}

.notification-info ol {
    padding-left: 1.2rem;
    line-height: 1.6;
}

.notification-info li {
    margin-bottom: 0.5rem;
    color: #424242;
}

.notification-form {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.notification-form .form-group {
    margin-bottom: 1rem;
}

.notification-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.notification-form input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.notification-form input[type="text"]:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

.notification-form small {
    display: block;
    margin-top: 0.25rem;
    color: #666;
    font-size: 0.875rem;
}

.notification-form input[type="checkbox"] {
    margin-right: 0.5rem;
    transform: scale(1.2);
}

.notification-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
}

.notification-form .form-group label {
    display: flex;
    align-items: center;
    font-weight: normal;
}

.topic-id-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.topic-id-input-group input {
    flex: 1;
}

.topic-id-input-group button {
    white-space: nowrap;
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
}

.notification-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.notification-btn {
    background: none;
    border: 1px solid #4285f4;
    color: #4285f4;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s ease;
}

.notification-btn:hover {
    background-color: #4285f4;
    color: white;
}

.test-notification {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.test-notification h3 {
    margin-bottom: 1rem;
    color: #333;
}

.test-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.test-form {
    display: inline-block;
}

.mobile-channel-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-channel-info h1 {
    margin: 0;
    font-size: 1.5rem;
}

.notification-btn.active {
    background-color: #4285f4;
    color: white;
}

.mobile-channel-item.active {
    background-color: #4285f4;
    color: white;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .notification-settings {
        padding: 1rem;
        height: auto;
        max-height: none;
    }

    .main-content {
        height: calc(100vh - 60px);
        overflow-y: auto;
    }

    .notification-form,
    .test-notification {
        padding: 1rem;
    }

    .notification-actions,
    .test-actions {
        flex-direction: column;
    }

    .notification-actions .btn,
    .test-actions .btn {
        width: 100%;
    }

    .topic-id-input-group {
        flex-direction: column;
        align-items: stretch;
    }

    .topic-id-input-group button {
        width: 100%;
        margin-top: 0.5rem;
    }

    .status-display {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .mobile-menu-btn {
        display: block;
    }
}