:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --text: #1e2433;
  --muted: #6b7385;
  --border: #e4e7ef;
  --field: #f7f8fb;
  --done: #15803d;
  --danger: #c4362c;
  --shadow: 0 1px 2px rgba(20, 30, 60, .04), 0 6px 20px rgba(20, 30, 60, .06);
  --shadow-hover: 0 2px 4px rgba(20, 30, 60, .06), 0 12px 28px rgba(20, 30, 60, .10);
  --radius: 16px;

  /* メモ＝オレンジ系 / タスク＝ブルー系 / 未完了＝ローズ系 */
  --memo: #c2570c;
  --memo-hover: #9a4409;
  --memo-grad: linear-gradient(135deg, #f59e0b, #ea580c);
  --memo-soft: #fff5ea;
  --memo-line: #f8d9b9;
  --task: #2563eb;
  --task-hover: #1d4fc4;
  --task-grad: linear-gradient(135deg, #3b82f6, #4f46e5);
  --task-soft: #eef4ff;
  --task-line: #cddcfb;
  --open: #be123c;
  --open-grad: linear-gradient(135deg, #f43f5e, #be123c);
  --open-soft: #fff0f3;
  --open-line: #f7cbd5;
  --review: #0f766e;
  --review-hover: #0b5d57;
  --review-grad: linear-gradient(135deg, #14b8a6, #0f766e);
  --review-soft: #ecfbf8;
  --review-line: #bfe9e1;
  --done-grad: linear-gradient(135deg, #22c55e, #15803d);
  --done-soft: #ecfaf1;
  --done-line: #bfe5cc;
}
.theme-done { --theme: var(--done); --theme-grad: var(--done-grad); --theme-soft: var(--done-soft); --theme-line: var(--done-line); }
.theme-review { --theme: var(--review); --theme-hover: var(--review-hover); --theme-grad: var(--review-grad); --theme-soft: var(--review-soft); --theme-line: var(--review-line); }

/* テーマ色の切り替え（各要素は --theme 系の変数を参照する） */
.theme-memo { --theme: var(--memo); --theme-hover: var(--memo-hover); --theme-grad: var(--memo-grad); --theme-soft: var(--memo-soft); --theme-line: var(--memo-line); }
.theme-task { --theme: var(--task); --theme-hover: var(--task-hover); --theme-grad: var(--task-grad); --theme-soft: var(--task-soft); --theme-line: var(--task-line); }
.theme-open { --theme: var(--open); --theme-grad: var(--open-grad); --theme-soft: var(--open-soft); --theme-line: var(--open-line); }

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 100% -10%, #e6ecff 0%, transparent 60%),
    radial-gradient(900px 400px at -10% 0%, #fff1e3 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Noto Sans JP", system-ui, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

svg { width: 1em; height: 1em; display: block; }

.page { max-width: 1120px; margin: 0 auto; padding: 24px 16px 48px; }

/* ---------- ヘッダー ---------- */
.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 28px 32px;
  border-radius: 20px;
  color: #fff;
  background: linear-gradient(120deg, #1e3a8a 0%, #4f46e5 55%, #7c3aed 100%);
  box-shadow: 0 10px 30px rgba(79, 70, 229, .25);
  margin-bottom: 20px;
}
.hero::after {
  content: "";
  position: absolute;
  right: -60px; bottom: -90px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.hero::before {
  content: "";
  position: absolute;
  right: 120px; top: -70px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
}
.hero h1 { margin: 2px 0 4px; font-size: 26px; font-weight: 700; letter-spacing: .02em; }
.hero-date { margin: 0; font-size: 13px; opacity: .8; letter-spacing: .05em; }
.hero-sub { margin: 0; font-size: 14px; opacity: .85; }
.hero-badge {
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .25);
  white-space: nowrap;
}

/* ---------- ダッシュボード ---------- */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.stat-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  border-radius: 12px;
  font-size: 22px;
  color: #fff;
  background: var(--theme-grad);
  box-shadow: 0 6px 14px color-mix(in srgb, var(--theme) 30%, transparent);
}
.stat-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-value {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--theme);
  font-variant-numeric: tabular-nums;
}
.stat-value small { font-size: 14px; font-weight: 500; margin-left: 4px; color: var(--muted); }
.stat-note { font-size: 12px; color: var(--muted); margin-top: 4px; }

.progress {
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--theme-soft);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--theme-grad);
  transition: width .5s ease;
}

/* ---------- パネル ---------- */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.panel {
  position: relative;
  overflow: hidden;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--theme-grad);
}

.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.panel-icon {
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 9px;
  font-size: 17px;
  color: var(--theme);
  background: var(--theme-soft);
}
.list-head {
  justify-content: space-between;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}
.pill {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 999px;
  color: var(--theme);
  background: var(--theme-soft);
  border: 1px solid var(--theme-line);
}

/* ---------- フォーム ---------- */
.form { display: flex; flex-direction: column; gap: 10px; }
.inline-form { flex-direction: row; }
.inline-form input { flex: 1; min-width: 0; }

input[type="text"], textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  padding: 10px 14px;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #a3a9b8; }
input[type="text"]:focus, textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--theme);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--theme) 15%, transparent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 18px;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  background: var(--theme-grad);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--theme) 30%, transparent);
  transition: transform .15s, box-shadow .15s, filter .15s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 8px 18px color-mix(in srgb, var(--theme) 35%, transparent); }
.btn:active { transform: translateY(0); }
.btn svg { font-size: 16px; }

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

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 26px 12px;
  border: 1.5px dashed var(--theme-line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--theme-soft) 50%, #fff);
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.fresh { animation: pop-in .3s ease both; }

/* メモカード（付箋風） */
.memo {
  position: relative;
  padding: 14px 16px 12px;
  background: var(--memo-soft);
  border: 1px solid var(--memo-line);
  border-radius: 12px;
  transition: transform .2s, box-shadow .2s;
}
.memo::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--memo-grad);
}
.memo:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(194, 87, 12, .12); }
.memo-title { font-weight: 700; color: var(--memo-hover); }
.memo-body { margin: 4px 0 6px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.meta svg { font-size: 13px; }

/* タスク行 */
.task {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.task:hover { border-color: var(--task-line); box-shadow: 0 4px 14px rgba(37, 99, 235, .08); }
.task.done { background: #f8fafc; }
.task-info { flex: 1; min-width: 0; }
.task-text { font-weight: 500; overflow-wrap: anywhere; transition: color .2s; }
.task.done .task-text { text-decoration: line-through; color: var(--muted); }

/* 丸型チェックボックス */
.task input[type="checkbox"] {
  appearance: none;
  flex-shrink: 0;
  width: 22px; height: 22px;
  margin: 0;
  border: 2px solid #c3cad8;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .2s, border-color .2s;
}
.task input[type="checkbox"]:hover { border-color: var(--task); }
.task input[type="checkbox"]::after {
  content: "";
  width: 6px; height: 11px;
  margin-top: -2px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform .15s;
}
.task input[type="checkbox"]:checked { background: var(--task-grad); border-color: transparent; }
.task input[type="checkbox"]:checked::after { transform: rotate(45deg) scale(1); }
.task input[type="checkbox"]:focus-visible { outline: 3px solid var(--task-line); outline-offset: 2px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 1px 9px;
  border-radius: 999px;
}
.badge-open { background: var(--open-soft); color: var(--open); border: 1px solid var(--open-line); }
.badge-done { background: #e7f6ec; color: var(--done); border: 1px solid #bfe5cc; }

.delete {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px; height: 34px;
  font-size: 17px;
  color: #9aa1b1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.delete:hover { color: var(--danger); background: #fdecea; border-color: #f6c9c4; }

/* ---------- 最新の振り返り（ダッシュボード） ---------- */
.latest-review {
  grid-column: 1 / -1;
  align-items: center;
  color: inherit;
  text-decoration: none;
  background: linear-gradient(90deg, var(--review-soft), var(--surface) 60%);
  border-color: var(--review-line);
}
.latest-week {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--review);
}
.latest-comment {
  margin: 2px 0 0;
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest-comment.is-empty { color: var(--muted); font-size: 14px; }
.latest-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--review);
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--review-soft);
  transition: background .15s;
}
.latest-review:hover .latest-link { background: var(--review-line); }

/* ---------- 週次の振り返り ---------- */
.review-panel { margin-top: 20px; scroll-margin-top: 20px; }
.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}
.review-list-head { margin-top: 0; padding-top: 0; border-top: none; }

.week-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
  background: var(--review-soft);
  border: 1px solid var(--review-line);
}
.week-label { flex: 1; text-align: center; display: flex; flex-direction: column; line-height: 1.4; }
.week-label strong { font-size: 15px; }
.week-status { font-size: 12px; color: var(--muted); }
.week-status.is-saved { color: var(--review); font-weight: 500; }
.week-btn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  font-size: 16px;
  color: var(--review);
  background: var(--surface);
  border: 1px solid var(--review-line);
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.week-btn:hover:not(:disabled) { background: var(--review-line); }
.week-btn:disabled { opacity: .35; cursor: default; }
.week-summary { margin: 0; font-size: 13px; color: var(--muted); }

.review-list { max-height: 420px; overflow-y: auto; padding-right: 4px; }
.review-item {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
}
.review-item:hover { border-color: var(--review-line); }
.review-item.is-selected {
  border-color: var(--review);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--review) 12%, transparent);
}
.review-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.review-week { font-weight: 700; font-size: 14px; color: var(--review-hover); }
.review-edit {
  font: inherit;
  font-size: 12px;
  padding: 3px 10px;
  color: var(--review);
  background: var(--review-soft);
  border: 1px solid var(--review-line);
  border-radius: 999px;
  cursor: pointer;
}
.review-edit:hover { background: var(--review-line); }
.review-comment { margin: 6px 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- スマホ ---------- */
@media (max-width: 900px) {
  .dashboard { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .hero { padding: 22px 20px; }
  .hero h1 { font-size: 22px; }
  .hero-badge { display: none; }
  .dashboard { gap: 10px; }
  .stat { padding: 14px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; font-size: 18px; border-radius: 10px; }
  .columns { grid-template-columns: 1fr; }
  .stat-value { font-size: 26px; }
  .review-grid { grid-template-columns: 1fr; }
}

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

@media (max-width: 560px) {
  .latest-review { flex-wrap: wrap; }
  .latest-link { margin-left: auto; }
}
