* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: #222; background: #f5f6f8; display: flex; flex-direction: column; height: 100vh;
}

#topbar {
  background: #fff; border-bottom: 1px solid #d9dce1; padding: 10px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; flex: 0 0 auto;
}
#topbar h1 { font-size: 16px; margin: 0; font-weight: 700; }
#topbar .meta { display: flex; gap: 16px; color: #667; font-size: 12px; }
#topbar .controls { display: flex; align-items: center; gap: 12px; font-size: 13px; margin-left: auto; }
#topbar select, #topbar button { font-size: 13px; padding: 3px 8px; }
#topbar button { cursor: pointer; border: 1px solid #b9c0c9; background: #f1f3f6; border-radius: 5px; }
#topbar button:hover { background: #e6e9ee; }

.legend { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; font-size: 12px; }
.legend .chip { display: inline-flex; align-items: center; gap: 5px; color: #445; }
.legend .chip i { width: 13px; height: 13px; border-radius: 3px; display: inline-block; }
.legend .chip small { color: #99a; }
.legend .today-swatch { background: #e8453c; width: 3px !important; height: 14px !important; border-radius: 0 !important; }

main#app { flex: 1 1 auto; overflow: auto; position: relative; }
main#app.dragging { user-select: none; }
/* ドラッグ横スクロールはカレンダー上だけ */
.lane, .timeline-head { cursor: grab; }
main#app.dragging .lane, main#app.dragging .timeline-head { cursor: grabbing; }
.loading, .error { padding: 40px; text-align: center; color: #778; }
.error { color: #c0392b; }

.canvas { position: relative; }

/* 行 */
.row { display: flex; align-items: stretch; }
.row.head { position: sticky; top: 0; z-index: 30; }
.info {
  position: sticky; left: 0; z-index: 10; background: #fff;
  display: flex; align-items: stretch; border-right: 2px solid #c4c9d2;
  border-bottom: 1px solid #e7e9ee;
}
.body-row:nth-child(even) .info { background: #fafbfc; }
.body-row:hover .info { background: #eef4fb; }

/* 完了(終了)行は背景をグレーアウト（文字色はそのまま。背景は不透明＝横スクロール時に裏のバーが透けない） */
.body-row.closed .info { background: #d3d7dd; }
.body-row.closed:hover .info { background: #cbd0d7; }
.body-row.closed .lane { background-color: #dde0e5; }

.info-head { background: #eef1f5 !important; font-weight: 700; z-index: 31; align-items: center; }
.head .timeline-head { background: #eef1f5; }

.c { padding: 0 6px; display: flex; align-items: center; font-size: 12px; overflow: hidden; border-right: 1px solid #eef0f3; flex: 0 0 auto; }
.c-rownum { width: 40px; justify-content: center; color: #99a; font-variant-numeric: tabular-nums; }
.c-id   { width: 56px;  justify-content: center; }
.c-id a { color: #2a6dc9; text-decoration: none; }
.c-id a:hover { text-decoration: underline; }
.c-task { width: 404px; white-space: nowrap; text-overflow: ellipsis; }
.c-task span { overflow: hidden; text-overflow: ellipsis; }
.task-link { cursor: pointer; }
.task-link:hover { color: #2a6dc9; text-decoration: underline; }
.c-asg  { width: 70px; gap: 4px; }
.c-num  { width: 64px; justify-content: center; }
.est-input {
  width: 52px; text-align: center; font: inherit; font-size: 12px; color: #222;
  border: 1px solid transparent; background: transparent; border-radius: 4px; padding: 1px 2px;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.est-input::-webkit-outer-spin-button, .est-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.est-input:hover { border-color: #9cc2ec; background: #e7f0fb; }
.est-input:focus { outline: none; border-color: #4a90e2; background: #fff; }
.c-date { width: 56px; justify-content: center; font-variant-numeric: tabular-nums; }
.c-date.past { color: #c0392b; }
.c-date.editable { position: relative; cursor: pointer; }
.c-date.editable:hover { background: #e7f0fb; box-shadow: inset 0 0 0 1px #9cc2ec; border-radius: 3px; }
.c-date.editable .dval { pointer-events: none; }
.c-date.editable .dval:empty::before, .c-date.editable .dval { color: inherit; }
/* ＋ 表示（未入力）は薄く */
.c-date.editable .dval { min-width: 1em; text-align: center; }
.c-date.editable .dval.empty { color: #c3c8d0; }
/* ネイティブ日付入力はセルを覆って透明に */
.c-date.editable .dpick {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; padding: 0; margin: 0; cursor: pointer;
}
.c-status { width: 112px; border-right: none; }

.asg-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.asg-select {
  flex: 1 1 auto; min-width: 0; border: 1px solid transparent; background: transparent;
  font: inherit; font-size: 12px; line-height: 22px; height: 24px; color: #222;
  padding: 0 2px; border-radius: 4px; cursor: pointer; -webkit-appearance: none; appearance: none;
}
.asg-select:hover { border-color: #9cc2ec; background: #e7f0fb; }
.asg-select:focus { outline: none; border-color: #4a90e2; background: #fff; }

.badge { font-size: 11px; padding: 1px 6px; border-radius: 10px; white-space: nowrap; }
.st-new { background: #eceff3; color: #556; }
.st-progress { background: #d6ebff; color: #15539e; }
.st-review { background: #fff1c9; color: #8a6d00; }
.st-closed { background: #e2f3e4; color: #2e7d44; }

/* 編集可能なステータス（バッジ風のプルダウン） */
.st-select {
  max-width: 100%; border: 1px solid transparent; border-radius: 10px;
  font: inherit; font-size: 11px; line-height: 18px; height: 20px; padding: 0 6px;
  cursor: pointer; -webkit-appearance: none; appearance: none;
}
.st-select:hover { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18); }
.st-select:focus { outline: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3); }
.st-select option { background: #fff; color: #222; } /* ドロップダウン内は既定配色 */

/* タイムライン ヘッダー */
.timeline-head { display: flex; flex-direction: column; }
.months { display: flex; height: 30px; }
.month-cell {
  border-right: 1px solid #c4c9d2; border-bottom: 1px solid #d9dce1;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #445; position: sticky;
}
.days { display: flex; height: 30px; }
.day-cell {
  border-right: 1px solid #eef0f3; border-bottom: 1px solid #d9dce1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 10px; line-height: 1.1; color: #667; flex: 0 0 auto;
}
.day-cell.weekend { background: #fce3c7; }
.day-cell.is-today { background: #ffe2df; }
.day-cell .dnum { font-weight: 600; }
.day-cell .dow { font-size: 9px; color: #99a; }

/* レーン & バー */
.lane { position: relative; flex: 0 0 auto; border-bottom: 1px solid rgba(0,0,0,0.10); }
/* スプレッドシートのようにセルにぴったり収まる角丸なしの矩形バー */
.bar {
  position: absolute; top: 0; bottom: 0;
  overflow: hidden; cursor: default;
}
.bar.done { opacity: 0.55; }
/* マイルストーン期日の★（セル中心） */
.milestone-star {
  position: absolute; top: 0; bottom: 0; display: flex; align-items: center;
  transform: translateX(-50%); color: #111; font-size: 15px; line-height: 1; z-index: 4;
}

/* 今日の縦線（固定情報列(z-index:10)より下にして、左固定列の下に隠れるようにする） */
.today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: #e8453c; z-index: 5; pointer-events: none; }

/* ===== チケット詳細モーダル ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
}
.modal {
  background: #fff; border-radius: 10px; width: min(900px, 100%); max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,0.35); overflow: hidden;
}
.modal-loading, .modal-error { padding: 40px; text-align: center; color: #667; }
.modal-error { color: #c0392b; }
.modal-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  border-bottom: 1px solid #e3e6ea; background: #f7f8fa;
}
.modal-title { font-size: 15px; font-weight: 700; flex: 1 1 auto; line-height: 1.4; }
.modal-title .mt-id { color: #2a6dc9; margin-right: 6px; }
.modal-open { font-size: 12px; color: #2a6dc9; text-decoration: none; white-space: nowrap; }
.modal-open:hover { text-decoration: underline; }
.modal-close {
  flex: 0 0 auto; border: none; background: transparent; font-size: 24px; line-height: 1;
  color: #889; cursor: pointer; padding: 0 4px; border-radius: 6px;
}
.modal-close:hover { background: #e6e9ee; color: #333; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-body h3 { font-size: 13px; color: #556; border-bottom: 1px solid #eceef1; padding-bottom: 5px; margin: 20px 0 10px; }

.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 16px; }
.meta-item { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.meta-k { font-size: 11px; color: #99a; }
.meta-v { color: #222; }

.desc { white-space: pre-wrap; font-size: 13px; line-height: 1.7; color: #222;
  background: #fafbfc; border: 1px solid #eceef1; border-radius: 6px; padding: 12px; }

.comments { display: flex; flex-direction: column; gap: 10px; }
.comment { border: 1px solid #eceef1; border-radius: 6px; padding: 10px 12px; }
.comment-head { display: flex; gap: 10px; align-items: baseline; font-size: 12px; color: #667; margin-bottom: 6px; }
.comment-head b { color: #333; font-size: 13px; }
.changes { margin: 0 0 6px; padding-left: 18px; font-size: 12px; color: #667; }
.changes li { margin: 1px 0; }
.notes { white-space: pre-wrap; font-size: 13px; line-height: 1.7; color: #222; }
.empty-note { color: #aab; font-size: 13px; }

/* ===== カテゴリ・グループ見出し ===== */
.group-row { display: flex; align-items: stretch; }
.group-label {
  position: sticky; left: 0; z-index: 11; display: flex; align-items: center; gap: 8px;
  padding: 0 10px; font-size: 12px; font-weight: 700; background: #fff2a8;
  border-bottom: 1px solid #e7e9ee; border-right: 2px solid #c4c9d2; cursor: pointer;
}
.group-label:hover { background: #ffeb78; }
.group-caret { font-size: 10px; color: #8a7400; width: 12px; flex: 0 0 auto; }
.group-name { color: #5a4d00; }
.group-count { color: #9a8a30; font-weight: 400; font-size: 11px; }
.group-lane { background: #fffbe0; border-bottom: 1px solid #e7e9ee; flex: 0 0 auto; }

/* チケット詳細: コメント投稿フォーム */
.comment-form { margin-top: 14px; border-top: 1px solid #eceef1; padding-top: 12px; }
.comment-input {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; line-height: 1.6;
  border: 1px solid #cdd3db; border-radius: 6px; padding: 8px 10px; resize: vertical; min-height: 60px;
}
.comment-input:focus { outline: none; border-color: #4a90e2; }
.comment-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.comment-note { font-size: 11px; color: #99a; }
.comment-post {
  flex: 0 0 auto; border: 1px solid #2a6dc9; background: #2a6dc9; color: #fff;
  font-size: 13px; padding: 6px 16px; border-radius: 6px; cursor: pointer;
}
.comment-post:hover { background: #225bab; }
.comment-post:disabled { background: #9bb6da; border-color: #9bb6da; cursor: default; }
