/* ===== 配色（ライトモード） ===== */
:root {
  --bg: #f2f4f8;
  --bg-tint: #e9edf6;
  --panel: #ffffff;
  --card: #f8fafc;
  --text: #171c26;
  --muted: #6b7686;
  --line: #e4e8f0;
  --card-line: #e0e5ee;
  --accent: #4560e6;
  --accent-hover: #3a52cc;
  --on-accent: #ffffff;   /* アクセント色の上に置く文字色 */
  --accent-soft: #eaeefe;
  --accent-line: #ccd6fb;
  --done: #1d7a4f;
  --done-soft: #e6f4ec;
  --done-line: #c2e3d1;
  --danger: #c0392f;
  --danger-soft: #fdeceb;
  --danger-line: #f3c9c5;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 28, 45, .05);
  --shadow: 0 1px 2px rgba(20, 28, 45, .05), 0 8px 24px -14px rgba(20, 28, 45, .35);
}

/* ===== 配色（ダークモード：OSの設定に自動で追従） ===== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --bg-tint: #171b24;
    --panel: #1a1f29;
    --card: #212734;
    --text: #e8ecf3;
    --muted: #96a0b2;
    --line: #2a313f;
    --card-line: #323a4a;
    --accent: #7b92ff;
    --accent-hover: #93a6ff;
    --on-accent: #10131a;
    --accent-soft: #232b45;
    --accent-line: #39456b;
    --done: #6bd1a0;
    --done-soft: #1c3129;
    --done-line: #2d4c3c;
    --danger: #ff9d94;
    --danger-soft: #3a2422;
    --danger-line: #59322e;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px -16px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 20px 64px;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 12% -8%, var(--bg-tint), transparent 70%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ===== ヘッダー ===== */
.site-header {
  max-width: 1040px;
  margin: 0 auto;
  padding: 36px 0 22px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 1.15rem;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.site-header h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.tagline {
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
}

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

/* ===== ダッシュボード ===== */
.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-sm);
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--line);
}
.stat-accent { background: var(--accent-soft); border-color: var(--accent-line); }
.stat-accent::before { background: var(--accent); }
.stat-label {
  display: block;
  font-size: .76rem;
  letter-spacing: .06em;
  color: var(--muted);
}
.stat-value {
  display: block;
  margin-top: 2px;
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.stat-accent .stat-value { color: var(--accent); }

/* 最新の振り返り（ダッシュボード内で横幅いっぱい） */
.stat-wide { grid-column: 1 / -1; }
.stat-wide::before { background: var(--accent); opacity: .45; }
.latest-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 3px;
}
.latest-week {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.latest-comment {
  margin: 6px 0 0;
  font-size: .9rem;
  white-space: pre-wrap;
  word-break: break-word;
  /* 長くても3行までにして、続きは一覧で読む */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest-comment.is-empty { color: var(--muted); }

/* ===== エラー表示 ===== */
.error {
  margin: 0 0 18px;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-line);
  font-size: .88rem;
}

/* ===== パネル ===== */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.panel h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.count {
  min-width: 24px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-size: .74rem;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* 一覧の表示切り替え */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .8rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  transition: background .15s, color .15s;
}
.toggle:hover { background: var(--card); color: var(--text); }
.toggle input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* ===== 入力欄 ===== */
.form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.form-inline { flex-direction: row; }
.form-inline input { flex: 1; }

/* 振り返りパネル */
.panel-review { margin-top: 18px; }
.week-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.field-label {
  font-size: .8rem;
  color: var(--muted);
  letter-spacing: .04em;
}
.week-row select { flex: 1; min-width: 220px; max-width: 360px; }
.hint {
  margin: -2px 0 0;
  font-size: .8rem;
  color: var(--muted);
}
.review-item .item-body { margin-top: 8px; }

input[type="text"], textarea, select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--card-line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .94rem;
  background: var(--card);
  color: inherit;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
select { cursor: pointer; }
input[type="text"]::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input[type="text"]:focus, textarea:focus, select:focus {
  outline: none;
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  font: inherit;
  font-size: .89rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background .15s, transform .08s, box-shadow .15s;
}
button:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== 一覧 ===== */
.list {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 1件ずつをカードにして、パネルの背景から浮かせる */
.list li {
  position: relative;
  background: var(--card);
  border: 1px solid var(--card-line);
  border-radius: var(--radius-sm);
  padding: 13px 15px 12px 17px;
  overflow: hidden;
  animation: item-in .2s ease-out;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.list li::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
}
.list li:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow-sm);
}

@keyframes item-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .list li { animation: none; }
  * { transition: none !important; }
}

.item-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.item-title {
  flex: 1;
  font-weight: 600;
  letter-spacing: .01em;
  word-break: break-word;
}
.item-body {
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .9rem;
  color: var(--text);
  opacity: .9;
}
.item-meta {
  margin-top: 9px;
  font-size: .75rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
  background: var(--panel);
  border: 1px solid var(--card-line);
  color: var(--muted);
}
.badge-done { background: var(--done-soft); border-color: var(--done-line); color: var(--done); }
.badge-open { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

/* 完了したタスクは控えめに */
.task-done { background: var(--panel); }
.task-done::before { background: var(--done); opacity: .5; }
.task-done .item-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }

.task-check {
  margin-top: 4px;
  width: 17px;
  height: 17px;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

/* 小さいボタン（削除） */
.btn-mini {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 3px 10px;
  font-size: .78rem;
  font-weight: 500;
  box-shadow: none;
  opacity: .8;
}
.btn-mini:hover { background: transparent; }
.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger);
  opacity: 1;
}

/* ===== 一覧が空 / 非表示のときの案内 ===== */
.empty {
  margin: 0;
  padding: 18px 0 10px;
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
}

/* ===== 画面が狭いとき ===== */
@media (max-width: 860px) {
  .columns { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  body { padding: 0 14px 48px; }
  .dashboard { grid-template-columns: 1fr 1fr; gap: 10px; }
  .dashboard .stat:last-child { grid-column: 1 / -1; }
  .stat-value { font-size: 1.8rem; }
  .site-header { padding: 26px 0 18px; }
  .panel { padding: 16px 15px 14px; }
  .toggle { font-size: .75rem; }
}
