/* ===========================================================
   タスク管理 — カンバンUI（Trelloのダークテーマの配置/余白/文字寸法に寄せた実装）
   参考にしたのはレイアウトの寸法のみ。ロゴ・商標・画像は使用しません。
   =========================================================== */

:root {
  /* 面 */
  --nav-bg: #1d2125;
  --list-bg: #101204;
  --card-bg: #22272b;
  --card-bg-hover: #282e33;
  --panel-bg: #282e33;
  --panel-bg-2: #22272b;

  /* 文字 */
  --text: #b6c2cf;
  --text-strong: #dee4ea;
  --text-subtle: #9fadbc;
  --text-faint: #8c9bab;

  /* 線・押せる面 */
  --line: rgba(166, 187, 208, 0.16);
  --btn-bg: rgba(166, 187, 208, 0.09);
  --btn-bg-hover: rgba(166, 187, 208, 0.18);
  --input-bg: #22272b;

  /* アクセント */
  --primary: #579dff;
  --primary-ink: #1d2125;
  --focus: #85b8ff;

  /* 期限の3段階（3日前=黄 → 2日前=オレンジ → 1日前/当日/超過=赤） */
  --due-yellow-bg: #43371f;
  --due-yellow-tx: #f5cd47;
  --due-orange-bg: #4a2b12;
  --due-orange-tx: #fec195;
  --due-red-bg: #4c221e;
  --due-red-tx: #f87168;

  /* 優先度ラベル */
  --lbl-high-bg: #5d1f1a;
  --lbl-high-tx: #ffd5d2;
  --lbl-mid-bg: #533f04;
  --lbl-mid-tx: #f8e6a0;
  --lbl-low-bg: #37485a;
  --lbl-low-tx: #cce0ff;

  --done: #4bce97;

  /* 寸法（Trelloの実寸に合わせる） */
  --nav-h: 56px;
  --board-header-h: 56px;
  --list-w: 272px;
  --gap: 16px;
  --r-card: 8px;
  --r-list: 12px;
  --r-input: 4px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background-color: #131a20;
  background-image:
    radial-gradient(1100px 620px at 12% -12%, #2c4b5b 0%, rgba(44, 75, 91, 0) 62%),
    radial-gradient(900px 520px at 92% 112%, #3b4a2f 0%, rgba(59, 74, 47, 0) 58%),
    linear-gradient(162deg, #1b2b34 0%, #16202a 56%, #131a20 100%);
  background-attachment: fixed;
  overflow: hidden;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 16px; height: 16px; flex: 0 0 auto; fill: currentColor; }

:where(button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* ---------- 上部ナビ（高さ56px） ---------- */
.topnav {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--nav-bg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.35);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r-input);
  color: var(--text-strong);
  text-decoration: none;
}
.brand:hover { background: var(--btn-bg); }

.brand-mark {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 5px;
  background: var(--primary);
  color: #fff;
}
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: .02em; }

.nav-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 780px;
  margin: 0 auto;
}
.nav-search-ico {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}
.nav-search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  font: inherit;
  color: var(--text-strong);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.nav-search-input::placeholder { color: var(--text-faint); }
.nav-search-input:focus { background: var(--nav-bg); border-color: var(--primary); outline: none; }
.nav-search-input::-webkit-search-cancel-button { filter: invert(0.7); }

/* ---------- ボード見出し（高さ56px） ---------- */
.board-header {
  height: var(--board-header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  background: rgba(0, 0, 0, 0.22);
}
.board-title {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
  font-weight: 700;
  color: #fff;
}
.board-header-actions { display: flex; align-items: center; gap: 8px; }

.hbtn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px;
  font: inherit; font-weight: 500;
  color: var(--text-strong);
  background: rgba(255, 255, 255, 0.12);
  border: 0; border-radius: var(--r-input);
  cursor: pointer;
}
.hbtn:hover { background: rgba(255, 255, 255, 0.2); }
.hbtn-sm { height: 28px; font-size: 13px; }

/* ---------- 検索中の絞り込み表示 ---------- */
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 20px;
  background: rgba(0, 0, 0, 0.28);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.filter-text { font-size: 13px; color: var(--text-strong); }

/* ---------- ボード本体（横スクロール） ---------- */
.board {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
  height: calc(100vh - var(--nav-h) - var(--board-header-h));
  padding: 12px 20px 20px;
  overflow-x: auto;
  overflow-y: hidden;
}
.board.has-filter { height: calc(100vh - var(--nav-h) - var(--board-header-h) - 37px); }

/* ---------- リスト（幅272px） ---------- */
.list {
  flex: 0 0 var(--list-w);
  width: var(--list-w);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 8px;
  background: var(--list-bg);
  border: 1px solid transparent;
  border-radius: var(--r-list);
  box-shadow: 0 1px 1px rgba(9, 30, 66, 0.25);
}
.list.drop-target {
  border-color: var(--primary);
  background: #161a10;
}

.list-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 8px 8px;
}
.list-title {
  flex: 1 1 auto;
  font-size: 14px; line-height: 20px; font-weight: 600;
  color: var(--text-strong);
}
.list-count {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.list-cards {
  display: flex; flex-direction: column; gap: 8px;
  padding: 0 4px 2px;
  margin: 0 -4px;
  overflow-y: auto;
  min-height: 8px;
}
.list-cards::-webkit-scrollbar,
.board::-webkit-scrollbar { width: 8px; height: 12px; }
.list-cards::-webkit-scrollbar-thumb,
.board::-webkit-scrollbar-thumb { background: rgba(166, 187, 208, 0.25); border-radius: 8px; }
.board::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }

.list-empty {
  padding: 6px 8px 10px;
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- カード ---------- */
.card {
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid transparent;
  border-radius: var(--r-card);
  box-shadow: 0 1px 1px rgba(9, 30, 66, 0.25);
  cursor: pointer;
}
.card:hover { background: var(--card-bg-hover); border-color: var(--line); }
.card.dragging { opacity: .45; }

.card-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.label {
  height: 16px; padding: 0 8px;
  display: inline-flex; align-items: center;
  font-size: 12px; line-height: 16px; font-weight: 700;
  border-radius: 8px;
}
.label-high { background: var(--lbl-high-bg); color: var(--lbl-high-tx); }
.label-mid { background: var(--lbl-mid-bg); color: var(--lbl-mid-tx); }
.label-low { background: var(--lbl-low-bg); color: var(--lbl-low-tx); }

.card-title-row { display: flex; align-items: flex-start; gap: 6px; }
.card-done-icon { color: var(--done); margin-top: 2px; }
.card-title {
  font-size: 14px; line-height: 20px;
  color: var(--text-strong);
  word-break: break-word;
  white-space: pre-wrap;
}
.card-title-empty { color: var(--text-faint); font-style: italic; }

.card-badges {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 6px;
  font-size: 12px; line-height: 16px;
  color: var(--text-subtle);
}
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  border-radius: var(--r-input);
}
.badge .ico { width: 14px; height: 14px; }
.due-yellow { background: var(--due-yellow-bg); color: var(--due-yellow-tx); font-weight: 600; }
.due-orange { background: var(--due-orange-bg); color: var(--due-orange-tx); font-weight: 600; }
.due-red { background: var(--due-red-bg); color: var(--due-red-tx); font-weight: 600; }

.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.card-tag {
  padding: 1px 8px;
  font-size: 12px; line-height: 16px;
  color: var(--text-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* ---------- カード追加（リスト下部のインライン入力） ---------- */
.add-card-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  font: inherit;
  color: var(--text-subtle);
  background: transparent;
  border: 0; border-radius: var(--r-card);
  cursor: pointer;
  text-align: left;
}
.add-card-btn:hover { background: var(--btn-bg-hover); color: var(--text-strong); }

.composer { margin-top: 8px; }
.composer-input {
  width: 100%;
  padding: 8px 12px;
  font: inherit;
  color: var(--text-strong);
  background: var(--card-bg);
  border: 1px solid var(--primary);
  border-radius: var(--r-card);
  resize: none;
  box-shadow: 0 1px 1px rgba(9, 30, 66, 0.25);
}
.composer-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }

/* ---------- 共通ボタン ---------- */
.btn {
  height: 32px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-weight: 500;
  color: var(--text-strong);
  background: var(--btn-bg);
  border: 0; border-radius: var(--r-input);
  cursor: pointer;
}
.btn:hover { background: var(--btn-bg-hover); }
.btn-primary { background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn-primary:hover { background: #85b8ff; }

.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  color: var(--text-subtle);
  background: transparent;
  border: 0; border-radius: var(--r-input);
  cursor: pointer;
}
.icon-btn:hover { background: var(--btn-bg-hover); color: var(--text-strong); }

/* ---------- モーダル ---------- */
.modal {
  position: fixed; inset: 0;
  z-index: 50;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px;
  overflow-y: auto;
}
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.64); }
.modal-panel {
  position: relative;
  width: 100%; max-width: 880px;
  padding: 12px 20px 16px;
  background: var(--panel-bg);
  border-radius: var(--r-list);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.modal-panel-sm { max-width: 520px; }

.modal-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 32px;
}
.modal-topbar-actions { display: flex; align-items: center; gap: 4px; }
.modal-heading { margin: 0; font-size: 16px; font-weight: 600; color: var(--text-strong); }

.list-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 4px 2px 10px;
  background: var(--btn-bg);
  border-radius: var(--r-input);
}
.list-chip-label { font-size: 12px; color: var(--text-faint); }
.list-chip-select {
  font: inherit; font-weight: 600;
  color: var(--text-strong);
  background: transparent;
  border: 0;
  padding: 4px 2px;
  cursor: pointer;
}
.list-chip-select option { background: var(--panel-bg); color: var(--text-strong); }

.modal-title-row {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 0 0;
}
.complete-toggle {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  color: var(--text-subtle);
  background: transparent;
  border: 0; border-radius: 50%;
  cursor: pointer;
}
.complete-toggle .ico { width: 20px; height: 20px; }
.complete-toggle:hover { background: var(--btn-bg-hover); }
.complete-toggle[aria-pressed="true"] { color: var(--done); }

.title-input {
  flex: 1 1 auto;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 20px; line-height: 28px; font-weight: 600;
  color: #fff;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-input);
}
.title-input:hover { background: var(--panel-bg-2); }
.title-input:focus { background: var(--input-bg); border-color: var(--primary); outline: none; }

.field-error { margin: 6px 0 0 38px; font-size: 12px; color: var(--due-red-tx); }

.modal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  margin-top: 16px;
}
.modal-main { min-width: 0; }
.modal-side { min-width: 0; }

.detail-section { margin-bottom: 20px; }
.section-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
  color: var(--text-subtle);
}
.section-head h2 {
  margin: 0;
  font-size: 14px; line-height: 20px; font-weight: 600;
  color: var(--text-strong);
}

.segmented { display: inline-flex; gap: 4px; }
.seg {
  height: 28px; padding: 0 14px;
  font: inherit; font-weight: 600;
  color: var(--text-subtle);
  background: var(--btn-bg);
  border: 1px solid transparent; border-radius: 8px;
  cursor: pointer;
}
.seg:hover { background: var(--btn-bg-hover); }
.seg[aria-checked="true"].seg-high { background: var(--lbl-high-bg); color: var(--lbl-high-tx); border-color: var(--lbl-high-tx); }
.seg[aria-checked="true"].seg-mid { background: var(--lbl-mid-bg); color: var(--lbl-mid-tx); border-color: var(--lbl-mid-tx); }
.seg[aria-checked="true"].seg-low { background: var(--lbl-low-bg); color: var(--lbl-low-tx); border-color: var(--lbl-low-tx); }

.date-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.date-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-faint); }
.date-field input {
  height: 32px; padding: 0 8px;
  font: inherit;
  color: var(--text-strong);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-input);
  color-scheme: dark;
}
.date-field input:focus { border-color: var(--primary); outline: none; }

.pill {
  height: 24px; padding: 0 8px;
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 700;
  border-radius: var(--r-input);
}
.pill.due-red { background: var(--due-red-bg); color: var(--due-red-tx); }
.pill.due-orange { background: var(--due-orange-bg); color: var(--due-orange-tx); }
.pill.due-yellow { background: var(--due-yellow-bg); color: var(--due-yellow-tx); }

.memo-input, .tag-input {
  width: 100%;
  padding: 8px 12px;
  font: inherit;
  color: var(--text-strong);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  resize: vertical;
}
.memo-input::placeholder, .tag-input::placeholder { color: var(--text-faint); }
.memo-input:focus, .tag-input:focus { border-color: var(--primary); outline: none; }
.tag-input { margin-top: 8px; }

.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 6px 2px 10px;
  font-size: 12px;
  color: var(--text-strong);
  background: var(--btn-bg);
  border-radius: 10px;
}
.tag-chip button {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  color: var(--text-subtle);
  background: transparent; border: 0; border-radius: 50%;
  cursor: pointer;
  font-size: 13px; line-height: 1;
}
.tag-chip button:hover { background: var(--btn-bg-hover); color: var(--text-strong); }

.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.activity li { font-size: 12px; line-height: 18px; color: var(--text-subtle); }
.activity time { display: block; color: var(--text-faint); }

.modal-body-text { margin: 12px 0 0; font-size: 14px; color: var(--text-strong); }
.modal-note { margin: 8px 0 0; font-size: 12px; color: var(--text-subtle); }
.modal-note strong { color: var(--due-red-tx); }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* ---------- トースト ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 16px;
  font-size: 13px; line-height: 19px;
  color: var(--text-strong);
  background: #1d2125;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}
.toast.toast-error { border-left-color: var(--due-red-tx); }

/* ---------- 幅が狭いとき（詳細を1カラムに） ---------- */
@media (max-width: 820px) {
  .modal-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .nav-search { max-width: none; }
}
