:root {
  /* 背景・面 */
  --bg: #f4f6f9;
  --panel: #ffffff;
  --stat-bg: #e8ecf2;
  --field: #f7f9fc;

  /* 文字 */
  --text: #1e2a38;
  --muted: #74818f;
  --faint: #97a2ae;

  /* 罫線 */
  --line: #e2e7ee;
  --line-soft: #edf1f6;

  /* アクセント */
  --accent: #2f6fd0;
  --accent-dark: #245aad;
  --accent-soft: #eaf1fc;
  --danger: #c8455a;
  --danger-soft: #fdeef1;
  --done: #2e8f60;
  --done-soft: #e8f5ee;

  /* 影 */
  --shadow-sm: 0 1px 2px rgba(20, 35, 55, .05);
  --shadow-md: 0 1px 2px rgba(20, 35, 55, .05), 0 6px 18px rgba(20, 35, 55, .06);
  --shadow-lg: 0 2px 4px rgba(20, 35, 55, .06), 0 12px 32px rgba(20, 35, 55, .10);

  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 64px;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN",
               "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------
   ヘッダー
   --------------------------------------------------------------- */
.site-header {
  position: relative;
  background: linear-gradient(135deg, #0a1b36 0%, #1c4d8f 100%);
  color: #fff;
  padding: 34px 20px 46px;
  text-align: center;
  overflow: hidden;
}
/* 斜めの光をうっすら重ねて平坦さをなくす */
.site-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 78% -10%, rgba(255,255,255,.16), transparent 60%);
  pointer-events: none;
}
.site-header h1 {
  position: relative;
  margin: 0;
  font-size: 2.1rem;
  font-weight: 600;
  letter-spacing: .03em;
}
.subtitle {
  position: relative;
  margin: 6px 0 0;
  font-size: .84rem;
  font-weight: 400;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, .72);
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------------------------------------------------------------
   ダッシュボード
   --------------------------------------------------------------- */
.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin: -28px 0 28px;
}
.stat {
  position: relative;
  background: var(--stat-bg);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.stat-label {
  display: block;
  font-size: .74rem;
  font-weight: 500;
  letter-spacing: .06em;
  color: var(--muted);
}
.stat-value {
  display: block;
  margin-top: 2px;
  font-size: 2.1rem;
  font-weight: 650;
  line-height: 1.15;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  color: #16263a;
}
.stat-done .stat-value { color: var(--done); }

/* 最新の振り返り（3枚のカードの下に横いっぱいで表示） */
.latest-review {
  grid-column: 1 / -1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.latest-review-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.latest-review-label {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--accent-dark);
}
.latest-review-week {
  font-size: .76rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.latest-review-text {
  margin: 6px 0 0;
  font-size: .92rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  /* 長い振り返りは3行までに畳む */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest-review-text.is-empty { color: var(--faint); font-size: .86rem; }

/* ---------------------------------------------------------------
   パネル
   --------------------------------------------------------------- */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 24px;
  box-shadow: var(--shadow-sm);
}
.panel h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 28px 0 12px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--line-soft);
}
.panel h2:first-child { margin-top: 0; }
.count {
  margin-left: auto;
  font-weight: 500;
  font-size: .74rem;
  letter-spacing: .02em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------
   フォーム
   --------------------------------------------------------------- */
/* 週次の振り返りパネル（2カラムの下に横いっぱい） */
.panel-review { margin-top: 20px; }

.form { display: flex; flex-direction: column; gap: 10px; }
.form input, .form textarea, .form select {
  font: inherit;
  color: var(--text);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
  resize: vertical;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.form input::placeholder, .form textarea::placeholder { color: var(--faint); }
.form input:hover, .form textarea:hover, .form select:hover { border-color: #d3dae4; }
.form input:focus, .form textarea:focus, .form select:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 208, .13);
}
.form select {
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.form-note {
  margin: -2px 0 0;
  font-size: .74rem;
  color: var(--faint);
}
.form button {
  font: inherit;
  font-weight: 600;
  font-size: .9rem;
  letter-spacing: .02em;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(36, 90, 173, .28);
  transition: background-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.form button:hover {
  background: var(--accent-dark);
  box-shadow: 0 3px 10px rgba(36, 90, 173, .26);
}
.form button:active { transform: translateY(1px); box-shadow: none; }

/* ---------------------------------------------------------------
   一覧
   --------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.item {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  margin-bottom: 10px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.item:last-child { margin-bottom: 0; }
.item:hover {
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.item-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.item-title {
  flex: 1;
  font-weight: 600;
  font-size: .95rem;
  line-height: 1.5;
  word-break: break-word;
}
.item-body {
  margin: 8px 0 0;
  padding-left: 1px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .9rem;
  color: #43505f;
}
.item-meta {
  margin-top: 10px;
  font-size: .72rem;
  letter-spacing: .02em;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* チェックボックス */
.item-head input[type="checkbox"] {
  flex: none;
  width: 17px;
  height: 17px;
  margin: 3px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* 状態バッジ */
.badge {
  border-radius: 999px;
  padding: 2px 9px;
  font-size: .69rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(200, 69, 90, .16);
}
.badge.is-done {
  color: var(--done);
  background: var(--done-soft);
  border-color: rgba(46, 143, 96, .16);
}

.item.done { background: #fcfdfe; }
.item.done .item-title {
  text-decoration: line-through;
  text-decoration-color: rgba(116, 129, 143, .5);
  color: var(--muted);
  font-weight: 500;
}

/* ---------------------------------------------------------------
   行内ボタン
   --------------------------------------------------------------- */
.icon-btn {
  font: inherit;
  flex: none;
  font-size: .74rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 6px;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
  opacity: .55;
  transition: opacity .15s ease, background-color .15s ease,
              border-color .15s ease, color .15s ease;
}
.item:hover .icon-btn, .icon-btn:focus-visible { opacity: 1; }
.icon-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}
.icon-btn.delete:hover {
  background: var(--danger-soft);
  border-color: rgba(200, 69, 90, .45);
  color: var(--danger);
}

/* 空のとき */
.empty {
  color: var(--faint);
  font-size: .85rem;
  text-align: center;
  padding: 22px 8px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: #fcfdfe;
}

/* ---------------------------------------------------------------
   画面幅が狭いとき
   --------------------------------------------------------------- */
@media (max-width: 820px) {
  .columns { grid-template-columns: 1fr; gap: 16px; }
}
@media (max-width: 520px) {
  main { padding: 0 14px; }
  .site-header h1 { font-size: 1.65rem; }
  .dashboard { gap: 12px; }
  .stat { padding: 14px 8px 12px; }
  .stat-label { font-size: .68rem; letter-spacing: .02em; }
  .stat-value { font-size: 1.6rem; }
  .panel { padding: 18px 16px 20px; }
  .icon-btn { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
