:root { 
    --primary: #2563eb; 
    --bg: #f8fafc; 
    --text: #1e293b; 
    --border: #e2e8f0; 
}

body { 
    font-family: sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    margin: 0; 
}

.container { 
    max-width: 1000px; 
    margin: 0 auto; 
    padding: 0 15px; /* スマホ用に余白を少し縮小 */
}

/* ======== ヘッダー ======== */
header { 
    background: #fff; 
    border-bottom: 1px solid var(--border); 
    margin-bottom: 20px; 
}
.header-container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; padding: 15px 0; }
.header-container h1 { margin: 0; font-size: 1.5rem; }
.header-right { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }

/* ======== コントロールパネル ======== */
.controls { 
    background: #fff; 
    padding: 20px; 
    border-radius: 8px; 
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.view-switch { display: flex; gap: 10px; }
.filter-section { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; flex: 1; }
.checkbox-group { display: flex; gap: 15px; flex-wrap: wrap; }

/* ======== ボタン共通デザイン ======== */
.btn { 
    padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; background: #64748b; color: #fff; text-decoration: none; 
    display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; font-size: 0.95rem;
    box-sizing: border-box; /* 追加: paddingをwidthに含めることではみ出しを防止 */
}
.btn-primary { background: var(--primary); }
.btn-admin { background: #0f172a; }

.view-switch button {
    padding: 8px 16px; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: pointer; color: #333; transition: all 0.2s ease;
}
.view-switch button.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: bold; }

/* ======== タスクリスト（テーブル形式） ======== */
/* スマホで横スクロールさせるためのラッパー */
#task-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.task-table { width: 100%; border-collapse: collapse; background: #fff; min-width: 600px; /* 最小幅を指定してスマホではスクロールさせる */ }
.task-table th, .task-table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.task-table th { background: #f1f5f9; font-weight: bold; color: #475569; white-space: nowrap; }
.task-table tbody tr { cursor: pointer; transition: background-color 0.2s; }
.task-table tbody tr:hover { background-color: #f8fafc; }
.task-table tr:last-child td { border-bottom: none; }
.task-title-cell { font-weight: bold; color: var(--primary); }
.task-date-cell { font-size: 0.9em; color: #666; white-space: nowrap; }

.badge { color: #fff; padding: 4px 8px; border-radius: 4px; font-size: 0.8rem; display: inline-block; white-space: nowrap; }

/* ======== 詳細画面・コメント関連 ======== */
.detail-page .container { padding-top: 20px; padding-bottom: 40px; }
.title-input { width: 100%; font-size: 1.5rem; padding: 10px; margin-bottom: 15px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 6px; }
.title-input:disabled { background: transparent; border-color: transparent; padding-left: 0; color: var(--text); }

.task-meta-grid { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 20px; background: #fff; padding: 15px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.meta-item { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 200px; }
.meta-item label { font-weight: bold; font-size: 0.9rem; color: #475569; }
.date-range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.comment-item { background: #fff; padding: 15px; margin-bottom: 15px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid var(--border); }
.comment-meta { font-size: 0.8rem; color: #64748b; margin-bottom: 8px; border-bottom: 1px solid #e2e8f0; padding-bottom: 5px;}
.comment-box { margin-top: 15px; display: flex; flex-direction: column; gap: 10px; }
.comment-box textarea { width: 100%; padding: 10px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 6px; min-height: 80px; font-family: inherit; }

.comment-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.btn-small { padding: 6px 12px; font-size: 0.85rem; border-radius: 4px; border: 1px solid var(--border); background: #f8fafc; cursor: pointer; color: #475569; }
.btn-small:hover { background: #e2e8f0; }
.btn-delete { color: #ef4444; border-color: #fca5a5; background: #fff; }
.btn-delete:hover { background: #fef2f2; }

/* ======== 管理者画面 ======== */
.admin-section { margin-top: 30px; }
.admin-panel { background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.admin-panel h3 { margin-top: 0; font-size: 1.1rem; border-bottom: 2px solid var(--border); padding-bottom: 10px; margin-bottom: 15px; }
.form-row { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.form-row input, .form-row select { padding: 8px; border: 1px solid var(--border); border-radius: 4px; box-sizing: border-box; }
.form-input { padding: 8px; border: 1px solid var(--border); border-radius: 4px; width: 100%; box-sizing: border-box; }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; min-width: 600px; }
.admin-table th, .admin-table td { border: 1px solid var(--border); padding: 10px; text-align: left; vertical-align: middle; }
.admin-table th { background: #f1f5f9; font-weight: bold; white-space: nowrap; }
.admin-table tr:hover { background-color: #f8fafc; }

#calendar { background: #fff; padding: 15px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.fc-event { cursor: pointer; }

/* ========================================================
   📱 スマホ用レスポンシブ設定 (画面幅 768px 以下)
======================================================== */
@media (max-width: 768px) {
    /* 修正: 全体を中央揃えにして左寄りを解消 */
    .header-container { flex-direction: column; align-items: center; text-align: center; }
    .header-right { width: 100%; justify-content: center; flex-direction: column; margin-top: 10px; gap: 10px; }
    
    .controls { flex-direction: column; align-items: stretch; padding: 15px; }
    .view-switch { justify-content: center; margin-bottom: 10px; }
    .view-switch button { flex: 1; }
    
    .actions { width: 100%; }
    .actions .btn { width: 100%; margin-top: 10px; }

    .task-meta-grid { flex-direction: column; gap: 15px; }
    .date-range { flex-direction: column; align-items: flex-start; gap: 5px; }
    .date-range span { display: none; } /* スマホでは「〜」を隠して縦並びに */
    .date-range input { width: 100%; box-sizing: border-box; }

    .form-row { flex-direction: column; align-items: stretch; }
    .form-row input, .form-row select, .form-row button { width: 100%; margin-bottom: 5px; box-sizing: border-box; }

    /* カレンダーの文字サイズをスマホ向けに少し小さく */
    .fc { font-size: 0.85em; }
    .fc-toolbar { flex-direction: column; gap: 10px; }
}