:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #e6e9ee;
  --line: #eef1f4;
  --text: #1c2430;
  --muted: #7c8794;
  --accent: #4a6284;
  --accent-dark: #3b5170;
  --accent-soft: #eef2f7;
  --danger: #a85560;
  --done: #4f7f63;
  --shadow: 0 1px 2px rgba(20, 30, 45, .04), 0 4px 16px rgba(20, 30, 45, .05);
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ヘッダー */
.header {
  background: var(--accent);
  color: #fff;
  padding: 22px 32px;
}
.header h1 {
  margin: 0 auto;
  max-width: 1040px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .18em;
}

.container { max-width: 1040px; margin: 0 auto; padding: 40px 24px 96px; }

/* ダッシュボード */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}
.stat {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px 20px;
  text-align: center;
  overflow: hidden;
}
/* 未完了タスクだけ、上辺の細いラインで軽く強調 */
.stat-accent::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--accent);
}
.stat-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .12em;
  line-height: 1.4;
}
.stat-value {
  font-size: 34px;
  font-weight: 600;
  line-height: 1.2;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}
.stat-accent .stat-value { color: var(--accent); }

/* ダッシュボード：最新の振り返り */
.latest {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin: 16px 0 40px;
}
.latest-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--muted);
}
.latest-week {
  margin-top: 6px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.latest-comment {
  margin-top: 6px;
  color: #47525f;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3; /* 長い振り返りは3行までにしてダッシュボードを圧迫しない */
  overflow: hidden;
}
.latest-empty { margin-top: 6px; color: #9aa4b0; }

/* カード */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.card h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--muted);
  margin: 0 0 16px;
}
.card h2:not(:first-of-type) {
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}
.count { font-weight: 400; font-size: 11px; letter-spacing: .04em; opacity: .85; }

.card-wide { margin-top: 20px; }

/* フォーム */
.form { display: flex; flex-direction: column; gap: 10px; }
.form-row { flex-direction: row; }
.form-row input { flex: 1; }
#review-form button[type="submit"] { align-self: flex-start; }

/* 週の選択 */
.week-picker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.week-picker label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .08em;
}
.week-picker input[type="date"] { width: auto; }
.week-range {
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.hint {
  margin: 0;
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 8px 12px;
}

input, textarea {
  font: inherit;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fcfdfe;
  color: inherit;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
textarea { resize: vertical; min-height: 92px; }
input::placeholder, textarea::placeholder { color: #aeb6c0; }
input:hover, textarea:hover { border-color: #d5dae1; }
input:focus, textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 98, 132, .12);
}

button {
  font: inherit;
  font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 22px;
  background: var(--accent);
  color: #fff;
  white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
button:hover { background: var(--accent-dark); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 一覧 */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  padding: 16px 14px;
  border-radius: 10px;
  border-bottom: 1px solid var(--line);
  transition: background-color .15s ease;
}
.list li:hover { background: #fafbfc; }
.list li:last-child { border-bottom: none; padding-bottom: 4px; }

.item-title { font-weight: 600; word-break: break-word; }
.item-body {
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 6px;
  color: #47525f;
}
.item-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
  letter-spacing: .03em;
  font-variant-numeric: tabular-nums;
}
.empty {
  color: #9aa4b0;
  font-size: 13px;
  padding: 32px 0;
  text-align: center;
  border-bottom: none;
}

/* タスク行 */
.task-row { display: flex; align-items: flex-start; gap: 14px; }
.task-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 4px 0 0;
  flex: none;
  cursor: pointer;
  accent-color: var(--accent);
}
.task-main { flex: 1; min-width: 0; }
.task-done .item-title { color: var(--muted); text-decoration: line-through; text-decoration-color: #c3cad2; }

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  border-radius: 999px;
  padding: 2px 10px;
  margin-left: 10px;
  vertical-align: 2px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-done { background: #edf4ef; color: var(--done); }

/* 振り返り一覧の行 */
.review-row { display: flex; align-items: flex-start; gap: 14px; }
.review-main { flex: 1; min-width: 0; }
.review-actions { display: flex; gap: 8px; flex: none; }

.btn-ghost, .btn-delete {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 999px;
  opacity: 0;
  transition: opacity .15s ease, color .15s ease, border-color .15s ease, background-color .15s ease;
}
.list li:hover .btn-delete,
.list li:hover .btn-ghost,
.btn-delete:focus-visible,
.btn-ghost:focus-visible { opacity: 1; }
.btn-delete:hover {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-ghost:hover {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

/* トースト */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: #2a3646;
  color: #fff;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: .04em;
  box-shadow: 0 6px 24px rgba(20, 30, 45, .18);
}

@media (max-width: 720px) {
  .header { padding: 18px 20px; }
  .header h1 { font-size: 15px; }
  .container { padding: 24px 16px 64px; }
  /* 狭い画面では4枚を横並びにせず2枚ずつ折り返す */
  .dashboard { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 24px; }
  .stat { padding: 16px 10px 14px; }
  .stat-value { font-size: 26px; margin-top: 6px; }
  .columns { grid-template-columns: 1fr; }
  .card { padding: 22px 18px; }
  .latest { padding: 16px 18px; margin-bottom: 24px; }
  .card-wide { margin-top: 12px; }
  /* タッチ環境では操作ボタンを常に表示する */
  .btn-delete, .btn-ghost { opacity: 1; }
}

@media (hover: none) {
  .btn-delete, .btn-ghost { opacity: 1; }
}
