/* ============================================================
   進捗管理 - カスタムCSS
   ============================================================ */

:root {
  --primary:      #4f46e5;
  --primary-dark: #3730a3;
  --success:      #059669;
  --warning:      #d97706;
  --danger:       #dc2626;
  --gray-50:      #f8fafc;
  --gray-100:     #f1f5f9;
  --gray-200:     #e2e8f0;
  --gray-400:     #94a3b8;
  --gray-600:     #475569;
  --gray-800:     #1e293b;
  --sidebar-w:    220px;
}

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

html { -webkit-text-size-adjust: 100%; }

/* 固定トップバーにアンカー先が隠れないように */
:target { scroll-margin-top: 72px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--gray-50);
  color: var(--gray-800);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden; /* SPでの意図しない横スクロールを防止 */
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-800);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid #334155;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  color: #cbd5e1;
  font-size: 13px;
  transition: background 0.15s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: #334155;
  color: #fff;
  text-decoration: none;
}
/* 現在ページをアクセントバーで明示 */
.sidebar-nav a.active {
  box-shadow: inset 3px 0 0 #818cf8;
  font-weight: 600;
}

.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid #334155;
  font-size: 12px;
  color: #94a3b8;
}
.sidebar-user span { display: block; font-weight: 600; color: #cbd5e1; }

/* ── Main content ───────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0; /* flexアイテムの最小幅で横はみ出しを防止 */
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  /* スクロールしてもタイトルと主要アクションを常に表示 */
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
  /* 長いプロジェクト名でも1行で省略 */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content { padding: 28px; flex: 1; }

/* ── Flash messages ─────────────────────── */
.flash {
  position: relative;
  padding: 12px 40px 12px 16px; /* 右は閉じるボタン分 */
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 13px;
  transition: opacity 0.35s, transform 0.35s;
}
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

.flash-close {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  color: inherit;
  opacity: 0.5;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
.flash-close:hover { opacity: 1; }

.flash-hide { opacity: 0; transform: translateY(-4px); }

/* ── Buttons ────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-submitting { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { box-shadow: 0 2px 8px rgba(79,70,229,.35); }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-outline  { background: #fff; color: var(--gray-600); border: 1px solid var(--gray-200); }
.btn-outline:hover { border-color: var(--gray-400); opacity: 1; background: var(--gray-50); }
.btn-sm       { padding: 5px 10px; font-size: 12px; }

/* ── Cards ──────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

/* テーブルを縁いっぱいに表示するカード (マイページ等) */
.table-card { padding: 0; overflow: hidden; }

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-100);
}

/* ── Forms ──────────────────────────────── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--gray-600);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 14px;
  color: var(--gray-800);
  background: #fff;
  transition: border-color 0.15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--gray-400); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}

/* 入力後に不正と分かったフィールドは赤枠で示す (未入力の時点では光らせない) */
input:user-invalid, select:user-invalid, textarea:user-invalid {
  border-color: var(--danger);
}
input:user-invalid:focus, select:user-invalid:focus, textarea:user-invalid:focus {
  box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}
textarea { resize: vertical; min-height: 80px; }

input[type="file"] { max-width: 100%; } /* 長いファイル名でのはみ出し防止 */

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Tables ─────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 10px 12px;
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ── Checkbox list (担当者選択など) ─────── */
.checkbox-list {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  overflow: hidden;
  /* メンバーが増えてもフォームが間延びしないようスクロールに */
  max-height: 240px;
  overflow-y: auto;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: normal;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.1s;
  margin: 0;
}
.checkbox-item:last-child { border-bottom: none; }
.checkbox-item:hover { background: var(--gray-50); }

.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
  /* Formsのリセットを上書き */
  padding: 0;
  border: none;
  box-shadow: none;
}

/* ── Status badges ──────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-todo     { background: var(--gray-100); color: var(--gray-600); }
.badge-progress { background: #dbeafe; color: #1e40af; }
.badge-done     { background: #d1fae5; color: #065f46; }
.badge-archived { background: #fef3c7; color: #92400e; }
.badge-overdue  { background: #fee2e2; color: #991b1b; }
.badge-admin    { background: #ede9fe; color: #4c1d95; }
.badge-leader   { background: #dbeafe; color: #1e40af; }
.badge-member   { background: var(--gray-100); color: var(--gray-600); }

/* ── Project list (フェーズ2a) ─────────── */
.list-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.list-controls-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}

.list-search-input {
  flex: 1;
  min-width: 160px;
  max-width: 320px;
}

.list-select {
  width: auto;
  flex-shrink: 0;
}

/* 担当者フィルタ (プロジェクト一覧: admin/leaderのみ) */
.assignee-filter { position: relative; flex-shrink: 0; }

.assignee-filter-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  padding: 10px;
  min-width: 220px;
  max-width: 300px;
}

.assignee-filter-options {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.assignee-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--gray-800);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.assignee-filter-option:hover { background: var(--gray-50); }
.assignee-filter-option input[type="checkbox"] {
  width: 15px; height: 15px; accent-color: var(--primary); flex-shrink: 0; padding: 0; border: none;
}

.assignee-filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-100);
}

.project-list {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}

.project-list-item {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-100);
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}
.project-list-item:last-child { border-bottom: none; }
.project-list-item:hover      { background: var(--gray-50); text-decoration: none; }

.pli-main {
  flex: 1;
  min-width: 0; /* テキスト省略のために必要 */
}

.pli-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pli-meta {
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 12px;
  color: var(--gray-600);
  flex-wrap: wrap;
  row-gap: 2px;
}

.pli-separator {
  margin: 0 8px;
  color: var(--gray-200);
}

.pli-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
  width: 200px;
}

.pli-deadline {
  font-size: 12px;
  color: var(--gray-400);
  white-space: nowrap;
}
.pli-deadline.overdue { color: var(--danger); font-weight: 600; }

.pli-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: flex-end;
}
.pli-progress .progress-bar {
  width: 100px;
  flex-shrink: 0;
  margin: 0;
}
.pli-progress span {
  font-size: 12px;
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

/* (プロジェクトリストのモバイル対応は ≤767px ブロックに統合) */

/* ── Project cards ──────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.project-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 18px;
  transition: box-shadow 0.15s;
}
.project-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }

.project-card h3 { font-size: 15px; margin-bottom: 6px; }
.project-card p  { font-size: 12px; color: var(--gray-400); margin-bottom: 12px; }

.project-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--gray-600);
  margin-bottom: 14px;
}

.progress-bar {
  height: 5px;
  background: var(--gray-100);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 14px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width 0.3s;
}

/* ── Task detail ────────────────────────── */
/* タスク詳細: 本文+添付サイドパネルの2カラム (タブレット以下は1カラム) */
.task-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1023px) {
  .task-detail-grid { grid-template-columns: 1fr; }
}

.task-meta {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 16px;
  font-size: 13px;
  margin-bottom: 16px;
}
.task-meta dt { color: var(--gray-400); font-weight: 500; }
.task-meta dd { min-width: 0; overflow-wrap: break-word; }

.overdue-date { color: var(--danger); font-weight: 600; }

/* ── Comments ───────────────────────────── */
.comment {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.comment-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.comment-body {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word; /* 長いURL等でカードが伸びないように */
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 10px 14px;
}
.comment-header {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;      /* SPで日時+削除ボタンが折り返せるように */
  gap: 2px 8px;
  font-size: 12px;
  color: var(--gray-400);
  margin-bottom: 4px;
}
.comment-header strong { color: var(--gray-800); }

/* ── Attachments ────────────────────────── */
.attachment-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13px;
}
.attachment-item .file-name { flex: 1; }
.attachment-item .file-size { color: var(--gray-400); font-size: 11px; }


/* ── Login page ─────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--gray-800) 0%, #312e81 100%);
  padding: 16px;
}
.login-box {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 50px rgba(15,23,42,.35);
}
.login-box h1 {
  font-size: 20px;
  text-align: center;
  margin-bottom: 24px;
}

/* ── Tabs ───────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Sidebar logo as link ───────────────── */
a.sidebar-logo { display: block; text-decoration: none; }
a.sidebar-logo:hover { text-decoration: none; opacity: 0.85; }

/* ── Mypage greeting ────────────────────── */
.mypage-greeting {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 24px;
}

/* ── Summary cards ──────────────────────── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.summary-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-top: 3px solid var(--gray-200);
  border-radius: 8px;
  padding: 20px 24px;
  text-decoration: none;
  color: inherit;
  display: block;
  transition: box-shadow 0.15s;
}
.summary-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); text-decoration: none; }

.summary-card-count {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
  color: var(--gray-800);
}

.summary-card-label { font-size: 12px; color: var(--gray-600); }

.summary-card-today   { border-top-color: var(--danger); }
.summary-card-today   .summary-card-count { color: var(--danger); }
.summary-card-week    { border-top-color: var(--warning); }
.summary-card-week    .summary-card-count { color: var(--warning); }
.summary-card-month   { border-top-color: #0ea5e9; }
.summary-card-month   .summary-card-count { color: #0ea5e9; }
.summary-card-overdue { border-top-color: var(--danger); }
.summary-card-overdue .summary-card-count { color: var(--danger); }

/* ── マイページ: 絞り込み・並び替えパネル ─────────── */
/* カード(.card)と同じ角丸・枠線・影でサイト全体のトンマナに合わせる */
.mypage-filter {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  margin-bottom: 20px;
  overflow: hidden;
}

.mypage-filter-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  text-align: left;
}
.mypage-filter-toggle:hover { background: var(--gray-50); }
.mypage-filter-toggle-icon { color: var(--gray-400); font-size: 12px; }

.mypage-filter-panel {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* display:flex は著者スタイルなので、[hidden]によるブラウザ標準のdisplay:noneより
   常に優先されてしまう。ここで明示しないとJSでhidden属性を付けても閉じない。 */
.mypage-filter-panel[hidden] { display: none; }

/* 1行目: 検索 + 並び替え + リセットを横並び (stretchで3つの高さを揃える) */
.mypage-filter-topline {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}

.mypage-filter-search { flex: 1 1 220px; min-width: 0; }

.mypage-filter-topline-actions {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-shrink: 0;
}

.mypage-filter-sort {
  width: auto;
  min-width: 170px;
  flex-shrink: 0;
}

.mypage-filter-reset { flex-shrink: 0; white-space: nowrap; }

/* 2〜3行目: ラベル + チップ群 */
.mypage-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mypage-filter-row-label {
  font-size: 12px;
  color: var(--gray-600);
  flex-shrink: 0;
  width: 40px;
}

.mypage-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

/* 通常状態は .btn-outline と同じ白地+グレー枠に揃える (選択中はプライマリのまま) */
.mypage-chip {
  background: #fff;
  border: 1px solid var(--gray-200);
  color: var(--gray-600);
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.mypage-chip:hover { background: var(--gray-50); border-color: var(--gray-400); }

/* 選択中: is-active クラス(とaria-pressed)だけで見た目が決まる。
   :hover / :focus より詳細度を高くして、クリック後にフォーカスが外れても塗りつぶしを維持する。 */
.mypage-chip-group .mypage-chip.is-active,
.mypage-chip-group .mypage-chip.is-active:hover,
.mypage-chip-group .mypage-chip.is-active:focus,
.mypage-chip-group .mypage-chip[aria-pressed="true"],
.mypage-chip-group .mypage-chip[aria-pressed="true"]:hover,
.mypage-chip-group .mypage-chip[aria-pressed="true"]:focus {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, .18);
}

/* ── Section title ──────────────────────── */
.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-200);
}

/* ── Priority badges ────────────────────── */
.badge-p-urgent { background: #fee2e2; color: #991b1b; }
.badge-p-a      { background: #ffedd5; color: #9a3412; }
.badge-p-b      { background: #dbeafe; color: #1e40af; }
.badge-p-c      { background: var(--gray-100); color: var(--gray-600); }

/* ── Maintenance badge (フェーズ6) ──────── */
.badge-maintenance { background: #e0e7ff; color: #3730a3; }

/* ── Done/archived toggles (フェーズ6) ──── */
.task-done-row { opacity: 0.4; }

/* ── Avatar (フェーズ7) ─────────────────── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.avatar-initials {
  display: inline-flex;       /* .avatar の inline-block を上書き（後発ルールが優先） */
  align-items: center;        /* 上下中央 */
  justify-content: center;    /* 左右中央 */
  border-radius: 50%;         /* .avatar に依存せず明示 */
  font-weight: 700;
  color: #fff;
  user-select: none;
  letter-spacing: 0;
  /* line-height は指定しない:
     line-height:1 は CJK フォントの非対称 em-metrics により
     グリフが行ボックス内で上下に偏るため、flexbox の align-items に完全に委ねる */
}

/* ── Image modal trigger button ─ */
.img-modal-trigger {
  background: none;
  border: none;
  padding: 0;
  cursor: zoom-in;
  display: inline-block;
}

/* ── Attachment image preview (フェーズ7) ─ */
.attachment-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  object-fit: contain;
  cursor: zoom-in;
  transition: opacity 0.15s;
  display: block;
}
.attachment-preview:hover { opacity: 0.85; }

.attachment-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  cursor: zoom-in;
  transition: opacity 0.15s;
  display: inline-block;
}
.attachment-thumb:hover { opacity: 0.85; }

.attachment-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Member context banner ──────────────── */
.member-context-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 13px;
  color: #1e40af;
  margin-bottom: 16px;
}

/* ── Utility ────────────────────────────── */
.text-right { text-align: right; }
.text-muted { color: var(--gray-400); font-size: 12px; }
.flex       { display: flex; }
.items-center { align-items: center; }
.gap-2      { gap: 8px; }
.gap-3      { gap: 12px; }
.mb-4       { margin-bottom: 16px; }
.mb-5       { margin-bottom: 20px; }
.mt-4       { margin-top: 16px; }
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}
.empty-state p { margin-bottom: 16px; }

/* ── Phase 8: ハンバーガー / ドラッグ / レスポンシブ ── */

/* ハンバーガーボタン (デスクトップは非表示) */
#nav-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 300;
  width: 40px;
  height: 40px;
  background: var(--gray-800);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px;
}
#nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* メニュー展開中はハンバーガーを×に変形 */
body.sidebar-open #nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.sidebar-open #nav-toggle span:nth-child(2) { opacity: 0; }
body.sidebar-open #nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* モバイルオーバーレイ */
#nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 190;
}
#nav-overlay.active { display: block; }

/* ドラッグハンドル */
.drag-handle {
  color: var(--gray-400);
  font-size: 18px;
  cursor: grab;
  padding: 4px 6px;
  flex-shrink: 0;
  user-select: none;
  line-height: 1;
}
.drag-handle:active { cursor: grabbing; }

/* 担当者ソートボタン */
.assignee-sort-btns { display: flex; gap: 4px; }

/* ── タブレット (≤1023px) ─────────────────── */
@media (max-width: 1023px) {
  :root { --sidebar-w: 180px; }
  .content { padding: 20px; }
  .topbar  { padding: 12px 20px; }
  .summary-cards { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .pli-right { width: 160px; }
}

/* ── モバイル (≤767px) ───────────────────── */
@media (max-width: 767px) {
  /* ハンバーガーボタン表示 */
  #nav-toggle { display: flex; }

  /* サイドバー: 初期非表示、スライドイン */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }

  /* サイドバー展開時、固定表示の×ボタン(#nav-toggle)とロゴ文字が重なるのを防ぐ */
  .sidebar.open .sidebar-logo {
    padding-left: 60px;
  }

  /* メインコンテンツ: フル幅 */
  .main {
    margin-left: 0;
    width: 100%;
  }

  /* トップバーにハンバーガー分の余白 */
  .topbar {
    padding-left: 60px;
    padding-right: 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar h1 { font-size: 15px; }

  .content { padding: 14px; }

  /* iOSのフォーカス時自動ズームを防止 (16px未満だと発火する) */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="date"],
  input[type="datetime-local"],
  input[type="search"],
  select,
  textarea { font-size: 16px; }

  /* タスクテーブル → カードレイアウト */
  table thead { display: none; }
  table, tbody, tr, td { display: block; }
  tr {
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #fff;
    position: relative;
  }
  tr:last-child { margin-bottom: 0; }
  tr:hover td { background: transparent; }
  td {
    padding: 3px 0;
    border-bottom: none;
    font-size: 13px;
  }
  /* data-label 付きセルのみ項目名を表示 */
  td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--gray-600);
    margin-right: 6px;
    font-size: 11px;
  }
  td:empty { display: none; }

  /* テーブル用カードはカード枠を外し、行カードのみ見せる */
  .table-card {
    border: none;
    background: transparent;
    padding: 0;
    overflow: visible;
    box-shadow: none;
  }

  /* フォーム */
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .task-meta { grid-template-columns: 96px 1fr; }
  .summary-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .summary-card { padding: 14px 16px; }
  .summary-card-count { font-size: 28px; }

  /* 検索・フィルタ: 2カラムグリッドでコンパクトに */
  .list-controls-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    align-items: center;
  }
  .list-search-input { grid-column: 1 / -1; max-width: none; }
  .list-select       { width: 100%; }
  .list-select-full  { grid-column: 1 / -1; } /* 単独セレクトは全幅に */
  .list-controls-inputs label { grid-column: 1 / -1; padding: 2px 0; }
  /* 検索ボタン: 入力欄と見分けが付くよう中央寄せ + ボタンらしい高さに */
  .list-controls-inputs .btn {
    grid-column: 1 / -1;
    justify-content: center;
    min-height: 42px;
  }

  /* 担当者フィルタ: 全幅ボタン + パネルも画面幅に収まるよう調整 */
  .assignee-filter { grid-column: 1 / -1; }
  .assignee-filter-toggle,
  #assignee-filter-toggle { width: 100%; justify-content: center; min-height: 42px; }
  .assignee-filter-panel { left: 0; right: 0; width: auto; max-width: none; }

  /* マイページ絞り込み: 検索は全幅、並び替え+リセットは横並び、チップは横スクロール */
  .mypage-filter-panel { padding: 12px 14px 14px; gap: 10px; }

  .mypage-filter-search { flex: 1 1 100%; }
  .mypage-filter-topline-actions { width: 100%; }
  .mypage-filter-sort { flex: 1; width: 100%; min-width: 0; }

  .mypage-filter-row { gap: 8px; }
  .mypage-filter-row-label { width: 34px; }

  /* チップは折り返さず横スクロール (スクロールバーは非表示、端まで流せるよう余白を相殺) */
  .mypage-chip-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-right: 14px;
    margin-right: -14px;
  }
  .mypage-chip-group::-webkit-scrollbar { display: none; }
  .mypage-chip { flex-shrink: 0; padding: 7px 14px; }

  /* プロジェクトリスト: 期限・進捗は下段に横並びで表示 (非表示にしない) */
  .project-list-item { flex-wrap: wrap; gap: 8px 12px; padding: 12px 14px; }
  .pli-right {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .pli-progress { flex: 1; justify-content: flex-end; }
  .pli-progress .progress-bar { flex: 1; width: auto; max-width: 140px; }

  /* ボタン群: タップしやすい高さを確保 */
  .flex.gap-2 { flex-wrap: wrap; }
  .btn    { font-size: 13px; min-height: 40px; }
  .btn-sm { min-height: 32px; }

  /* フォームの保存/キャンセル行: 均等幅で押しやすく */
  .card form > .flex.gap-2 .btn {
    flex: 1;
    justify-content: center;
  }

  /* 行内の操作ボタン列: カード内で上と区切る */
  .row-actions {
    margin-top: 8px;
    padding-top: 8px !important;
    border-top: 1px solid var(--gray-100);
  }

  /* メンバーリスト: ドラッグハンドル非表示 */
  .drag-handle { display: none; }
}

/* ── 小モバイル (≤480px) ─────────────────── */
@media (max-width: 480px) {
  .summary-cards { grid-template-columns: 1fr; }
  .tabs { overflow-x: auto; }
}

/* ── アクセシビリティ: アニメーション抑制設定を尊重 ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ── アクセシビリティ: キーボードフォーカスの可視化 ── */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
