/* Team Board — 値はすべてtokens.cssから引く（design-system v0.1 憲法準拠） */

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

/* hidden属性は常に効かせる（.board=grid・.whoami=inline-flex等のdisplay指定に負けないよう） */
[hidden] { display: none !important; }

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  line-height: var(--lh-body);
  -webkit-font-smoothing: auto;
  text-rendering: optimizeLegibility;
}

/* --- ヘッダー --- */
.head {
  border-bottom: var(--bd);
  background: var(--paper);
}
.head-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--sp-5) var(--gutter) var(--sp-4);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3);
}
.whoami {
  display: inline-flex;
  align-items: baseline;
  gap: var(--sp-2);
  font-size: var(--fs-small);
  color: var(--ink-faint);
  white-space: nowrap;
}
.logout-btn {
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-family: inherit;
  font-size: var(--fs-small);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.logout-btn:hover { color: var(--ink); }

/* --- タブ（ボード／カレンダー） --- */
.tabs {
  max-width: var(--container);
  margin: calc(-1 * var(--sp-2)) auto 0; /* head-innerの下余白を詰めてヘッダーに寄せる */
  padding: 0 var(--gutter);
  display: flex;
  gap: var(--sp-4);
}
.tab {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-small);
  color: var(--ink-faint);
  padding: var(--sp-2) 0;
  margin-bottom: -1px; /* ヘッダー下端の罫線に重ねる */
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.is-active {
  color: var(--ink);
  font-weight: var(--fw-semi);
  border-bottom-color: var(--pcp-gold);
}

/* --- ログイン画面 --- */
.login {
  max-width: 360px;
  margin: var(--sp-7) auto;
  padding: 0 var(--gutter);
}
.login-form { display: flex; flex-direction: column; gap: var(--sp-3); }
.login-label {
  font-size: var(--fs-label);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--ink-faint);
}
.login-input {
  border: none;
  border-bottom: 1px solid var(--line);
  padding: var(--sp-2) 0;
  font-family: inherit;
  font-size: var(--fs-body);
  color: var(--ink);
  background: transparent;
}
.login-input:focus { outline: none; border-bottom-color: var(--pcp-gold); }
.login-btn {
  align-self: flex-start;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: inherit;
  font-size: var(--fs-small);
  padding: var(--sp-2) var(--sp-4);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.login-btn:hover { background: var(--paper); color: var(--ink); }
.login-error { color: var(--warn); font-size: var(--fs-small); }

.kicker {
  font-size: var(--fs-label);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--ink-faint);
  display: block;
}
/* P.C.P.ロゴ（kickerテキストの差し替え）。アイブロウ相当の高さに抑える */
.kicker-logo {
  display: block;
  height: 1.15rem;
  width: auto;
  margin-bottom: var(--sp-1);
}
.title {
  font-size: var(--fs-h3);
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  margin-top: var(--sp-1);
}

/* --- ボード（メンバーカードのグリッド） --- */
.board {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--sp-5) var(--gutter) var(--sp-7);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-4);
  align-items: start;
}
@media (max-width: 720px) {
  .board { grid-template-columns: 1fr; padding-top: var(--sp-4); }
}

.member-card {
  background: var(--paper);
  border: var(--bd);
  border-radius: var(--r-none);
  padding: var(--sp-4);
}
.member-name {
  font-size: 1.1rem;
  font-weight: var(--fw-bold);
  padding-bottom: var(--sp-2);
  border-bottom: var(--bd);
  margin-bottom: var(--sp-2);
}

/* --- タスク行 --- */
.task-list { list-style: none; }
.task {
  display: flex;
  flex-wrap: wrap; /* 備考パネルを行の下へ折り返す（flex-basis:100%で新しい行に落とす） */
  align-items: baseline;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none; /* 長押しでiOSの選択メニューを出さない（備考オープンと競合防止） */
  touch-action: manipulation; /* iOSのダブルタップズームを抑止（完了トグルとの競合防止） */
}
.task:last-child { border-bottom: none; }

.task .box {
  flex: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--pcp-greige);
  border-radius: var(--r-sm);
  position: relative;
  top: 2px;
  transition: border-color var(--dur-fast) var(--ease);
}
.task .name {
  flex: 1;
  font-size: var(--fs-small);
  color: var(--ink);
  overflow-wrap: anywhere;
}
.task .meta {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
}
/* 期日ドット：期日あり=ゴールド／なし=黒。ボタン化しクリックで期日設定。
   透明パディングで見た目8px・タップ領域は約16pxに広げる（background-clipで色は中心のみ） */
.task .dot {
  flex: none;
  box-sizing: content-box;
  width: 8px;
  height: 8px;
  padding: 4px;
  border: none;
  border-radius: 50%;
  background-clip: content-box;
  cursor: pointer;
  position: relative;
  top: 1px;
}
.task .dot-due { background-color: var(--pcp-gold); }
.task .dot-none { background-color: var(--ink); }
.task .dot:hover { filter: brightness(1.15); }

/* 期日を選ぶ小さなカレンダー（2026-08-24・ネイティブの日付入力から差し替え）。
   ドットの下に浮かせるのでpositionはfixed＝行の折り返しに影響しない。
   見た目はカレンダータブに合わせる（今日＝黒丸／選択中＝金の下地） */
.due-pop {
  position: fixed;
  z-index: var(--z-overlay);
  width: 252px;
  max-width: calc(100vw - 16px);
  background: var(--paper);
  border: var(--bd-ink);
  box-shadow: var(--sh-card);
}
.due-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2);
  border-bottom: var(--bd);
}
.due-pop-ym {
  font-size: var(--fs-small);
  font-weight: var(--fw-bold);
  color: var(--ink);
}
.due-pop-nav {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  color: var(--ink-faint);
  padding: 4px 10px;
  cursor: pointer;
}
.due-pop-nav:hover { color: var(--ink); }

.due-pop-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: var(--bd);
}
.due-pop-dow {
  background: var(--paper-alt);
  font-size: var(--fs-label);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-tag);
  color: var(--ink-faint);
  text-align: center;
  padding: 4px 0;
}
.due-pop-dow.sun { color: var(--warn); }
.due-pop-dow.sat { color: var(--pcp-gold-ink); }

.due-pop-day {
  background: var(--paper);
  border: none;
  border-radius: 0;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--ink-muted);
  /* 指で押せる高さを確保する（スマホの誤タップ防止） */
  min-height: 36px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.due-pop-day:hover { background: var(--paper-alt); }
.due-pop-day.sun { color: var(--warn); }
.due-pop-day.sat { color: var(--pcp-gold-ink); }
/* 前月・翌月の日付は曜日色より薄さを優先する（sun/satより後に置いて上書きさせる） */
.due-pop-day.out { color: var(--placeholder-b); background: var(--paper-alt); }
.due-pop-day.selected { background: var(--pcp-gold-wash); font-weight: var(--fw-bold); }
.due-pop-day.today {
  background: var(--ink);
  color: var(--paper);
}
.due-pop-day.today.selected { background: var(--pcp-gold-ink); color: var(--paper); }

.due-pop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2);
}
.due-pop-foot > :only-child { margin-left: auto; } /* 「閉じる」だけの時は右に寄せる */
.due-pop-clear,
.due-pop-cancel {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-label);
  white-space: nowrap;
  padding: 4px 2px;
  cursor: pointer;
}
.due-pop-clear { color: var(--warn); }
.due-pop-cancel { color: var(--ink-faint); }
.due-pop-cancel:hover { color: var(--ink); }
.task .due {
  font-size: 0.72rem;
  font-family: ui-monospace, monospace;
  color: var(--ink-faint);
}
/* 期限切れ：期日と名前を警告色に。⚠️バッジで一目で気づける */
.task .due.overdue { color: var(--warn); font-weight: var(--fw-semi); }
.task.overdue .name { color: var(--warn); }
/* 期日超過の「超過」ハンコ。赤字だけだと見落とすので、タイトルの頭に四角で囲って置く。
   少し傾けて押印っぽく見せる（2026-08-22 Yuuki指示）。
   タイトル要素の中にinlineで入れる＝行の独立した列にするとタイトルが細く潰れるため */
.stamp-overdue {
  display: inline-block;
  margin-right: 0.4em;
  padding: 1px 4px;
  border: 1px solid var(--warn);
  border-radius: 2px;
  color: var(--warn);
  font-size: 0.66rem;
  font-weight: var(--fw-bold);
  line-height: 1.3;
  letter-spacing: 0.06em;
  white-space: nowrap;
  vertical-align: 1px;
  transform: rotate(-4deg);
}

/* --- 編集・削除（誤入力の即時修正） --- */
.task .controls {
  flex: none;
  display: flex;
  gap: 2px;
}
.icon-btn {
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1;
  padding: var(--sp-1);
  cursor: pointer;
}
.icon-btn:hover { color: var(--ink); }
.icon-btn-delete:hover { color: var(--pcp-gold-ink); }
.icon-btn-hide { display: inline-flex; align-items: center; }
/* 非表示中のタスクは目アイコンをゴールドにして「自分だけに見えている」を示す */
.task.private .icon-btn-hide { color: var(--pcp-gold-ink); }

/* 非表示中（本人にだけ薄く表示。左に細いゴールド罫線で"自分だけ"を示す） */
.task.private {
  opacity: 0.72;
  border-left: 2px solid var(--pcp-gold);
  padding-left: var(--sp-2);
  margin-left: calc(-1 * var(--sp-2) - 2px);
}

.edit-input {
  flex: 1;
  min-width: 0;
  border: none;
  border-bottom: 1px solid var(--pcp-gold);
  padding: 0;
  font-family: inherit;
  font-size: var(--fs-small);
  color: var(--ink);
  background: transparent;
}
.edit-input:focus { outline: none; }

/* --- 備考（1タスク=1メモ欄。PC=クリック / モバイル=長押しで開く） --- */
.note-badge {
  flex: none;
  font-size: 0.72rem;
  line-height: 1;
  position: relative;
  top: 1px;
}
.note-panel {
  flex-basis: 100%; /* 行を折り返して備考をタスクの下に全幅で表示 */
  width: 100%;
  margin-top: var(--sp-2);
}
.note-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: var(--sp-2);
  font-family: inherit;
  font-size: var(--fs-small);
  line-height: var(--lh-body);
  color: var(--ink);
  background: var(--paper-alt);
  resize: vertical;
}
.note-input:focus { outline: none; border-color: var(--pcp-gold); }

/* 完了（取り消し線・猶予中はダブルタップで復活） */
.task.done .name {
  text-decoration: line-through;
  color: var(--ink-faint);
}
.task.done .box {
  border-color: var(--pcp-gold);
}
.task.done .box::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--pcp-gold);
  border-radius: 1px;
}

/* --- タスク追加 --- */
.add-form { margin-top: var(--sp-2); }
.add-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: var(--sp-1) 0;
  font-family: inherit;
  font-size: var(--fs-small);
  color: var(--ink);
  background: transparent;
}
.add-input::placeholder { color: var(--pcp-greige); }
.add-input:focus { outline: none; border-bottom-color: var(--pcp-gold); }

/* --- 空状態 --- */
.empty {
  font-size: var(--fs-small);
  color: var(--ink-faint);
  padding: var(--sp-2) 0;
}

/* カレンダーから飛んできたタスクを一瞬光らせる（どれを見に来たか見失わないため） */
.task.flash {
  background: var(--pcp-gold-wash);
  transition: background 1.2s var(--ease);
}

/* --- カレンダービュー（閲覧専用） --- */
.calendar {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--sp-5) var(--gutter) var(--sp-7);
}
@media (max-width: 720px) {
  .calendar { padding: var(--sp-4) var(--gutter) var(--sp-6); }
}

.cal-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.cal-nav {
  border: var(--bd);
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.1rem;
  line-height: 1;
  padding: var(--sp-1) var(--sp-3);
  cursor: pointer;
}
.cal-nav:hover { border-color: var(--ink); }
.cal-month {
  font-size: var(--fs-h3);
  font-weight: var(--fw-bold);
  min-width: 9ch;
  text-align: center;
}
.cal-today-btn {
  margin-left: var(--sp-2);
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font-family: inherit;
  font-size: var(--fs-small);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  white-space: nowrap; /* 狭い画面で「今／月」に折れるのを防ぐ */
}
.cal-today-btn:hover { color: var(--ink); }

/* 7列グリッド。セル間の隙間を背景色で見せて罫線を引かずに区切る */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--line);
  border: var(--bd);
}
.cal-dow {
  background: var(--paper-alt);
  font-size: var(--fs-label);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-tag);
  color: var(--ink-faint);
  text-align: center;
  padding: var(--sp-2) 0;
}
.cal-dow.sun { color: var(--warn); }
.cal-dow.sat { color: var(--pcp-gold-ink); }

.cal-cell {
  background: var(--paper);
  border: none;
  border-radius: 0;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  min-height: 104px;
  padding: var(--sp-1);
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: stretch;
  -webkit-tap-highlight-color: transparent;
}
.cal-cell:hover { background: var(--paper-alt); }
.cal-cell.out { background: var(--paper-alt); }
.cal-cell.selected { background: var(--pcp-gold-wash); }

.cal-day {
  font-size: 0.78rem;
  font-family: ui-monospace, monospace;
  color: var(--ink-muted);
  line-height: 1.4;
}
.cal-cell.sun .cal-day { color: var(--warn); }
.cal-cell.sat .cal-day { color: var(--pcp-gold-ink); }
/* 前月・翌月の日付は曜日色より薄さを優先する（sun/satより後に置いて上書きさせる） */
.cal-cell.out .cal-day { color: var(--placeholder-b); }
/* 今日は日付を黒丸で反転させる（罫線を増やさずに一点だけ強くする） */
.cal-cell.today .cal-day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  align-self: flex-start;
}

.cal-chips { display: flex; flex-direction: column; gap: 2px; }
.cal-chip {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 0.7rem;
  line-height: 1.3;
  padding: 2px 3px;
  background: var(--paper-alt);
  border-left: 2px solid transparent;
  overflow: hidden;
}
/* 自分のタスクだけ左罫をゴールドにする（5人分を色分けせず自分だけ拾えるようにする） */
.cal-chip.mine { border-left-color: var(--pcp-gold); }
.cal-chip-tag {
  flex: none;
  font-weight: var(--fw-semi);
  color: var(--ink-faint);
  font-size: 0.62rem;
  letter-spacing: 0.02em;
}
.cal-chip-name {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-chip.done .cal-chip-name {
  text-decoration: line-through;
  color: var(--ink-faint);
}
.cal-chip.overdue .cal-chip-name { color: var(--warn); font-weight: var(--fw-semi); }
.cal-more {
  font-size: 0.65rem;
  color: var(--ink-faint);
  padding-left: 3px;
}

/* 狭い画面用の点。広い画面ではチップを出すので隠す */
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; align-items: center; }
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
}
.cal-dot.done { background: var(--pcp-greige); }
.cal-dot.overdue { background: var(--warn); }
.cal-dot-plus {
  font-size: 0.6rem;
  line-height: 1;
  color: var(--ink-faint);
}

@media (max-width: 720px) {
  .cal-cell { min-height: 56px; }
  .cal-chips { display: none; }
  .cal-dots { display: flex; }
  .cal-cell.today .cal-day { width: 1.35rem; height: 1.35rem; }
}

/* 日をタップしたときの吹き出し（位置はJSが計算してleft/topを入れる） */
.cal-grid-wrap { position: relative; }
.cal-pop {
  position: absolute;
  z-index: var(--z-overlay);
  width: min(300px, calc(100% - 8px));
  background: var(--paper);
  border: var(--bd-ink);
  box-shadow: var(--sh-card);
}
.cal-pop-arrow {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--paper);
  transform: translate(-50%, -50%) rotate(45deg);
}
.cal-pop.is-below .cal-pop-arrow {
  top: 0;
  border-left: var(--bd-ink);
  border-top: var(--bd-ink);
}
.cal-pop.is-above .cal-pop-arrow {
  top: 100%;
  border-right: var(--bd-ink);
  border-bottom: var(--bd-ink);
}
.cal-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-bottom: var(--bd);
}
.cal-pop-title {
  font-size: var(--fs-label);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-label);
  color: var(--ink);
}
.cal-pop-close {
  flex: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  color: var(--ink-faint);
  padding: 2px 4px;
  cursor: pointer;
}
.cal-pop-close:hover { color: var(--ink); }
.cal-pop-body {
  max-height: 40vh;
  overflow-y: auto;
  padding: var(--sp-1) var(--sp-2);
}
.cal-pop .cal-item { flex-wrap: wrap; gap: var(--sp-1); }
.cal-pop .cal-item-who { width: auto; }
.cal-pop .cal-list li:last-child { border-bottom: none; }
.cal-pop .empty { padding: var(--sp-2); }

/* 吹き出しの下の追加欄（カレンダーで書き込めるのはここだけ） */
.cal-add {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-top: var(--bd);
}
.cal-add-input { flex: 1; min-width: 0; }
/* 追加ボタン。指で押せる大きさを確保する（スマホのキーボードのEnterに頼らないための入り口） */
.cal-add-send {
  flex: none;
  font-size: var(--fs-label);
  font-weight: var(--fw-bold);
  color: var(--pcp-gold-ink);
  white-space: nowrap;
  padding: var(--sp-1) var(--sp-2);
}

/* 期日なし一覧 */
.cal-undated { margin-top: var(--sp-5); }
.cal-detail-head {
  font-size: var(--fs-label);
  font-weight: var(--fw-semi);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-bottom: var(--sp-2);
  border-bottom: var(--bd);
}
.cal-list { list-style: none; }
/* 1行＝タップでボードへ飛ぶ本体 ＋ 自分のタスクだけ付く✎× */
.cal-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.cal-row:hover { background: var(--paper-alt); }
.cal-item {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  border: none;
  border-left: 2px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: var(--fs-small);
  text-align: left;
  padding: var(--sp-2);
  cursor: pointer;
}
.cal-item.mine { border-left-color: var(--pcp-gold); }
.cal-item-controls {
  flex: none;
  display: flex;
  gap: 2px;
  padding-right: var(--sp-1);
}
/* 指で押す前提なので、この2つだけ上下の余白を足して押せる範囲を広げる */
.cal-item-controls .icon-btn { padding: var(--sp-2) var(--sp-1); }
.cal-item-who {
  flex: none;
  width: 6.5em;
  font-size: var(--fs-label);
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-item-title { flex: 1; color: var(--ink); overflow-wrap: anywhere; }
.cal-item.done .cal-item-title {
  text-decoration: line-through;
  color: var(--ink-faint);
}
.cal-item.overdue .cal-item-title { color: var(--warn); font-weight: var(--fw-semi); }
@media (max-width: 720px) {
  .cal-item { flex-wrap: wrap; gap: var(--sp-1); }
  .cal-item-who { width: auto; }
}
