:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --border: #e2e6ee;
  --text: #1f2430;
  --muted: #7b8494;
  --accent: #3563e9;
  --accent-dark: #2748b8;
  --danger: #d84a4a;
  --today: #e60012;
  --done: #8b93a3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 48px;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.site-header {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 0 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
}

.site-header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

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

/* ダッシュボード */
/* スクロールしても常に見えるようにする */
.dashboard-area {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 10px 0 14px;
  background: var(--bg);
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* 最新の振り返り */
.latest-review {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
}

.latest-review.is-empty { border-left-color: var(--border); }

.latest-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.latest-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.is-empty .latest-label { color: var(--muted); }

.latest-week {
  font-size: 0.85rem;
  font-weight: 600;
}

.latest-updated {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--muted);
}

/* 2行までにして、固定表示が高くなりすぎないようにする */
.latest-comment {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: #4a5262;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.is-empty .latest-comment { color: var(--muted); }

.week-badge {
  padding: 1px 8px;
  border-radius: 999px;
  background: #e8eeff;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 600;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.stat-accent { border-color: var(--accent); }

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-accent .stat-value { color: var(--accent); }

/* パネル */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 1px 9px;
}

/* 入力フォーム */
.form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.form input,
.form textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.95rem;
  background: #fbfcfe;
  resize: vertical;
}

.form input:focus,
.form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  background: #fff;
}

/* カレンダー */
.calendar-panel { margin-bottom: 20px; }

.calendar-head {
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 420px;
  margin-bottom: 12px;
}

.calendar-head h2 {
  margin: 0;
  min-width: 7.5em;
  justify-content: center;
}

.cal-nav {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.cal-nav:hover { background: #eef2fd; border-color: var(--accent); }

.cal-today-btn {
  margin-left: auto;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.cal-today-btn:hover { background: #eef2fd; }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  max-width: 420px;
  /* 横スワイプはこちらで受け取り、縦スクロールはブラウザに任せる */
  touch-action: pan-y;
  user-select: none;
}

.cal-head {
  padding: 2px 0;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
}

.cal-day {
  padding: 8px 0;
  text-align: center;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fbfcfe;
}

/* 今日のマス */
.cal-day.is-today {
  background: var(--today);
  border-color: var(--today);
  color: #fff;
  font-weight: 700;
}

/* 週次の振り返り */
.review-panel { margin-top: 20px; }

.week-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.week-field label {
  font-size: 0.82rem;
  color: var(--muted);
}

.week-field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.92rem;
  background: #fbfcfe;
}

.week-field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* 画像の選択 */
.file-field {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.file-field input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-label {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}

.file-label:hover { background: #eef2fd; }

.file-field input[type="file"]:focus + .file-hint,
.file-field input[type="file"]:focus ~ .file-label { outline: 2px solid var(--accent); }

.file-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

/* 追加前のプレビュー */
.preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview:empty { display: none; }

.preview-item {
  position: relative;
  width: 72px;
  height: 72px;
}

.preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.preview-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}

/* メモ内の画像 */
.memo-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.memo-images img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: block;
}

.memo-images a:hover img { border-color: var(--accent); }

.form button {
  align-self: flex-start;
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.form button:hover { background: var(--accent-dark); }

/* 一覧 */
/* 一覧が長くなってもページ全体は伸ばさず、この中でスクロールさせる */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.list:not(:empty) { padding-right: 4px; }

.item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfe;
}

/* 完了タスクの見出し */
.list-label {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.item-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.item-head .item-title { flex: 1; min-width: 0; }
.item-head .item-meta { margin-top: 0; }

.item-title {
  margin: 0;
  font-size: 0.97rem;
  font-weight: 600;
  word-break: break-word;
}

/* 長い本文は4行までにして、必要なときだけ広げる */
.item-body {
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  color: #4a5262;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}

.item-body.open {
  display: block;
  overflow: visible;
}

.more-btn {
  margin-top: 4px;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.more-btn:hover { text-decoration: underline; }

.item-meta {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  white-space: nowrap;
}

/* タスク項目 */
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.task-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.task-main { flex: 1; min-width: 0; }

.task-done { background: #f6f7fa; }

.task-done .item-title {
  text-decoration: line-through;
  color: var(--done);
}

/* 内容の邪魔をしないよう、ふだんは薄いグレーの×にしておく */
.delete-btn {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: #b6bcc8;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.delete-btn:hover,
.delete-btn:focus-visible {
  background: #fdeaea;
  color: var(--danger);
}

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 4px 0 0;
}

/* トースト */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #1f2430;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 720px) {
  .columns { grid-template-columns: 1fr; }

  /* 画面が狭くても3列のまま小さくまとめる（縦積みだと固定表示が場所を取りすぎるため） */
  .stat { padding: 8px 6px; }
  .stat-label { font-size: 0.7rem; }
  .stat-value { font-size: 1.4rem; }
  .list { max-height: 50vh; }
}
