:root {
  --bg: #e5eaf2;
  --card: #ffffff;
  --item: #f5f7fb;
  --line: #c2ccd9;
  --line-soft: #dbe2ec;
  --text: #0f1724;
  --muted: #435065;
  --accent: #1d5fbf;
  --accent-dark: #123f86;
  --accent-soft: #dce8fb;
  /* 未完了の色(青と合う紫) */
  --warn: #6a2fb8;
  --warn-soft: #f0e8fd;
  --warn-line: #c6acef;
  --danger: #a5170e;
  --danger-soft: #fde3e0;
  --shadow: 0 1px 2px rgba(12, 24, 48, .08), 0 3px 10px rgba(12, 24, 48, .07);
  --input-line: #8b9ab0;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", "Hiragino Sans", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ヘッダー */
header { background: var(--accent-dark); color: #fff; border-bottom: 4px solid var(--accent); }
h1 { max-width: 1080px; margin: 0 auto; padding: 16px 20px; font-size: 1.35rem; letter-spacing: .06em; }

/* 各欄の見出し(左に色付きの線) */
h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--line-soft);
  font-size: 1.1rem;
}
h2::before { content: ""; width: 5px; height: 1.1em; border-radius: 3px; background: var(--accent); }

main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 40px; }

/* ダッシュボード */
.dashboard { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
  display: flex;
  flex-direction: column;
  padding: 14px 20px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 5px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
/* 改行は <wbr> の位置だけにする(「完了タスク件 / 数」のように切れないように) */
.stat-label { color: var(--muted); font-size: .9rem; font-weight: bold; word-break: keep-all; }
.stat-value { color: var(--muted); font-size: .95rem; font-weight: bold; }
.stat-value b { margin-right: 4px; color: var(--text); font-size: 2.4rem; line-height: 1.15; }
.stat-open { background: var(--warn-soft); border-color: var(--warn-line); border-top-color: var(--warn); }
.stat-open .stat-label, .stat-open .stat-value, .stat-open b { color: var(--warn); }

/* ダッシュボードの「最新の振り返り」 */
.latest-review {
  margin-bottom: 24px;
  padding: 16px 22px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.latest-review-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 8px; }
.latest-review-head h2 { margin: 0; padding: 0; border: 0; }
.latest-review-head h2::before { display: none; }
.more-link { margin-left: auto; color: var(--accent); font-size: .88rem; font-weight: bold; }
.latest-review .review-comment {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4; /* 長いときは4行まで表示 */
}

/* 週次の振り返り */
.week-label { color: var(--accent-dark); font-weight: bold; }
.review-comment { margin: 4px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.reviews { margin-top: 24px; }
.reviews-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 28px; align-items: start; }
.sub-heading { margin: 0 0 12px; font-size: 1rem; }
.hint { min-height: 1.6em; margin: -8px 0 14px; color: var(--accent-dark); font-size: .88rem; font-weight: bold; }

/* 2列の配置 */
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.column { display: grid; gap: 24px; min-width: 0; }
.card {
  min-width: 0;
  padding: 20px 22px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

/* 入力欄 */
label { display: block; margin-bottom: 6px; color: var(--text); font-size: .9rem; font-weight: bold; }
input[type="text"], input[type="date"], textarea {
  display: block;
  width: 100%;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1.5px solid var(--input-line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  font: inherit;
}
input[type="text"]:focus, input[type="date"]:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }

button { border: 0; border-radius: 8px; font: inherit; font-weight: bold; cursor: pointer; }
button:disabled { opacity: .6; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.primary { padding: 10px 22px; background: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-dark); }
.primary:hover { background: var(--accent-dark); }

/* 一覧(1件ずつ枠で囲む) */
.list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.list li {
  padding: 12px 14px;
  background: var(--item);
  border: 1px solid var(--line-soft);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  overflow-wrap: anywhere;
}
.empty { margin: 0; padding: 14px; border: 1.5px dashed var(--line); border-radius: 8px; color: var(--muted); text-align: center; }
time { color: var(--muted); font-size: .82rem; }

.memo-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.memo-title { min-width: 0; margin: 0; font-size: 1.05rem; font-weight: bold; }
.memo-body { margin: 4px 0 6px; white-space: pre-wrap; }
.memo-head .memo-body { flex: 1; min-width: 0; margin-top: 0; }

/* タスク: 未完了は紫、完了は青の線 */
.list li.task { display: flex; align-items: center; gap: 12px; border-left-color: var(--warn); }
.list li.task.done { background: #edf1f7; border-left-color: var(--accent); }
.list li.task { flex-wrap: wrap; }
.task-main { flex: 1 1 12em; min-width: 0; }
.task-title { font-weight: bold; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 2px; }
.task.done .task-title { color: var(--muted); font-weight: normal; text-decoration: line-through; }
.badge {
  padding: 0 9px;
  border: 1px solid var(--warn-line);
  border-radius: 99px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: .78rem;
  font-weight: bold;
}
.task.done .badge { border-color: #9dbbe8; background: var(--accent-soft); color: var(--accent-dark); }

.task-actions { display: flex; flex-shrink: 0; gap: 6px; }
.review-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.review-actions { display: flex; flex-shrink: 0; gap: 6px; }

.task-actions button, .memo-head button, .review-actions button {
  flex-shrink: 0;
  padding: 5px 12px;
  background: #fff;
  border: 1.5px solid var(--input-line);
  font-size: .85rem;
  white-space: nowrap;
}
.task-actions .toggle, .task-actions .edit, .memo-head .edit, .review-actions .edit { border-color: var(--accent); color: var(--accent-dark); }
.task-actions .toggle:hover, .task-actions .edit:hover, .memo-head .edit:hover, .review-actions .edit:hover { background: var(--accent-soft); }

/* 作成日時と「編集済み」を同じ行に並べる */
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.edited-tag {
  display: inline-block; /* 完了タスクの取り消し線がかからないように */
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.6;
  font-weight: normal;
  white-space: nowrap;
}
.task-title .edited-tag { margin-left: 8px; vertical-align: 2px; }

/* 一覧の中での編集 */
.item-actions { display: flex; flex-shrink: 0; gap: 6px; }
.list li.editing { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.edit-form { flex: 1; min-width: 0; }
.edit-form label { margin-bottom: 12px; }
.edit-form input[type="text"], .edit-form textarea { margin: 6px 0 0; font-weight: normal; }
.review-edit-form textarea { margin: 6px 0 12px; }
.task-edit-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.task-edit-form input[type="text"] { flex: 1 1 14em; margin: 0; }
.secondary { padding: 10px 18px; background: #fff; border: 1.5px solid var(--input-line); color: var(--text); }
.secondary:hover { background: var(--item); }
.task-actions .delete, .memo-head .delete, .review-actions .delete { border-color: #d99a95; color: var(--danger); }
.task-actions .delete:hover, .memo-head .delete:hover, .review-actions .delete:hover { background: var(--danger-soft); }

.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.form-status { margin: 0; color: var(--accent-dark); font-weight: bold; }
.form-status.is-error { color: var(--danger); }

/* エラーは画面を下にスクロールしていても上部に表示され続ける */
.error {
  position: sticky;
  top: 8px;
  z-index: 10;
  box-shadow: var(--shadow);
  margin: 0 0 24px;
  padding: 12px 16px;
  border: 1.5px solid #e0a29d;
  border-left: 5px solid var(--danger);
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: bold;
}

@media (max-width: 720px) {
  main { padding: 16px 14px 32px; }
  .columns { grid-template-columns: 1fr; gap: 16px; }
  .column { gap: 16px; }
  .dashboard { gap: 8px; margin-bottom: 16px; }
  .stat { padding: 10px 10px 12px; }
  .stat-label { font-size: .74rem; }
  .stat-value b { font-size: 1.8rem; }
  .card { padding: 16px; }
  .reviews { margin-top: 16px; }
  .reviews-grid { grid-template-columns: 1fr; gap: 20px; }
  .latest-review { margin-bottom: 16px; padding: 14px 16px; }
}
