/* ---- デザイントークン（白ベース・カラフル） ---- */
:root {
  color-scheme: light; /* OS がダークモードでも常に白ベースで表示 */

  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-muted: #f8f9fc;
  --border: #eaecf2;
  --border-strong: #d6dae4;
  --text: #1e2230;
  --text-muted: #5f6678;
  --text-faint: #9aa0b0;

  /* テーマカラー */
  --violet: #8b5cf6;
  --violet-dark: #7c3aed;
  --violet-soft: #f1ebff;
  --sky: #0ea5e9;
  --sky-dark: #0284c7;
  --sky-soft: #e3f4fd;
  --orange: #f97316;
  --orange-soft: #fff0e5;
  --pink: #ec4899;
  --pink-dark: #db2777;
  --pink-soft: #fde9f3;
  --green: #22c55e;
  --green-dark: #16a34a;
  --green-soft: #e6f8ed;
  --red: #ef4444;
  --red-soft: #feecec;

  --shadow-sm: 0 1px 3px rgba(30, 34, 48, 0.06);
  --shadow-md: 0 8px 24px rgba(30, 34, 48, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
}

/* ---- ベース ---- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, rgba(139, 92, 246, 0.10), transparent 40%),
    radial-gradient(circle at 100% 0%, rgba(14, 165, 233, 0.10), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(249, 115, 22, 0.06), transparent 45%),
    var(--bg);
  background-attachment: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main { max-width: 1120px; margin: 0 auto; padding: 32px 20px 64px; }

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- ヘッダー ---- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--violet), var(--pink) 55%, var(--orange));
  color: #fff;
  box-shadow: 0 8px 20px rgba(236, 72, 153, 0.3);
}
.logo svg { width: 24px; height: 24px; stroke-width: 2.3; }
h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--violet-dark), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.subtitle { margin: 0; font-size: 0.85rem; color: var(--text-muted); }
.today {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--violet-dark);
  background: var(--surface);
  border: 1px solid var(--violet-soft);
  padding: 6px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

/* ---- ダッシュボード ---- */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  --c: var(--violet);
  --c-soft: var(--violet-soft);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--c);
}
.stat-memo { --c: var(--violet); --c-soft: var(--violet-soft); }
.stat-task { --c: var(--sky); --c-soft: var(--sky-soft); }
.stat-pending { --c: var(--orange); --c-soft: var(--orange-soft); }
.stat-done { --c: var(--green-dark); --c-soft: var(--green-soft); }

.stat-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--c-soft);
  color: var(--c);
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-body { flex: 1; min-width: 0; }
.stat-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }
.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--c);
  font-variant-numeric: tabular-nums;
}

.progress {
  height: 8px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--orange-soft);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--orange), var(--pink));
  border-radius: 999px;
  transition: width 0.4s ease;
}
.progress-label { margin-top: 4px; font-size: 0.75rem; color: var(--text-faint); }

/* ---- パネル ---- */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.panel {
  --c: var(--violet);
  --c-dark: var(--violet-dark);
  --c-soft: var(--violet-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.panel-memo { --c: var(--violet); --c-dark: var(--violet-dark); --c-soft: var(--violet-soft); }
.panel-task { --c: var(--sky); --c-dark: var(--sky-dark); --c-soft: var(--sky-soft); }

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.panel-title::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 4px var(--c-soft);
}
.panel-title:not(:first-child) {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px dashed var(--border-strong);
}
.count {
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--c-soft);
  color: var(--c-dark);
  border-radius: 999px;
  padding: 0 9px;
  min-width: 24px;
  text-align: center;
}

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

/* 優先度の色（高＝赤・中＝オレンジ・低＝グレー） */
.priority-high { --p: #b91c1c; --p-line: #ef4444; --p-soft: #feecec; }
.priority-medium { --p: #b45309; --p-line: #f59e0b; --p-soft: #fff4dc; }
.priority-low { --p: #475569; --p-line: #94a3b8; --p-soft: #eef2f6; }

/* 追加フォームの優先度選択 */
.priority-picker { display: flex; align-items: center; gap: 6px; }
.priority-picker-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-right: 4px; }
.priority-option { position: relative; cursor: pointer; }
.priority-option input { position: absolute; opacity: 0; pointer-events: none; }
.priority-option span {
  display: inline-block;
  min-width: 44px;
  padding: 3px 12px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.priority-option:hover span { border-color: var(--p-line); color: var(--p); }
.priority-option input:checked + span { background: var(--p-soft); border-color: var(--p-line); color: var(--p); }
.priority-option input:focus-visible + span { box-shadow: 0 0 0 3px var(--p-soft); }
.form-actions { display: flex; justify-content: flex-end; }

input[type="text"], textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input[type="text"]::placeholder, textarea::placeholder { color: var(--text-faint); }
input[type="text"]:focus, textarea:focus {
  background: var(--surface);
  border-color: var(--c);
  box-shadow: 0 0 0 4px var(--c-soft);
}
textarea { resize: vertical; min-height: 84px; }

button { font: inherit; cursor: pointer; }
.btn-primary {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 22px;
  background: linear-gradient(135deg, var(--c), var(--c-dark));
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  box-shadow: 0 4px 12px var(--c-soft);
  transition: filter 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 6px 16px var(--c-soft); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--c-soft); }

/* ---- 一覧 共通 ---- */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.list li:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.list li.empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-faint);
  background: var(--surface-muted);
  border: 1.5px dashed var(--border-strong);
  transform: none;
  box-shadow: none;
}

.meta { font-size: 0.75rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.meta time { white-space: nowrap; }

/* ---- メモ（付せん風に色分け） ---- */
.memo {
  --m: var(--violet);
  --m-bg: #f6f1ff;
  background: var(--m-bg) !important;
  border-color: transparent !important;
  border-left: 5px solid var(--m) !important;
}
.memo.c0 { --m: #8b5cf6; --m-bg: #f6f1ff; } /* 紫 */
.memo.c1 { --m: #ec4899; --m-bg: #fdf0f7; } /* ピンク */
.memo.c2 { --m: #f59e0b; --m-bg: #fff8e6; } /* 黄 */
.memo.c3 { --m: #10b981; --m-bg: #ebfaf3; } /* 緑 */
.memo.c4 { --m: #0ea5e9; --m-bg: #eaf6fd; } /* 水色 */

.memo-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.memo-title { font-weight: 700; word-break: break-word; }
.memo-head .meta { flex-shrink: 0; }
.memo-body {
  margin-top: 6px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- タスク ---- */
.group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--orange);
}
.group-label.is-done { color: var(--green-dark); }
.group-label:first-child { margin-top: 0; }
.group-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.task { display: flex; align-items: center; gap: 14px; border-left: 5px solid var(--orange) !important; }
.task .meta { display: flex; align-items: center; flex-wrap: wrap; row-gap: 4px; }
.task-main { flex: 1; min-width: 0; }
.task-text { font-weight: 500; word-break: break-word; margin-bottom: 2px; }
/* 未完了タスクの左線は優先度の色 */
.task.priority-high, .task.priority-medium, .task.priority-low { border-left-color: var(--p-line) !important; }
.task.done { background: var(--surface-muted); border-left-color: var(--green) !important; }

/* 一覧の優先度プルダウン（ラベル風の見た目） */
.priority-select {
  appearance: none;
  -webkit-appearance: none;
  margin: 0 8px 0 0;
  padding: 0 20px 0 9px;
  border: none;
  border-radius: 999px;
  background: var(--p-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 7px center / 8px;
  color: var(--p);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.7;
  cursor: pointer;
  vertical-align: middle;
}
.priority-select:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--p-soft); }
.task.done .priority-select { opacity: 0.6; }
.task.done .task-text { font-weight: 400; color: var(--text-faint); text-decoration: line-through; }

/* 丸いチェックボックス */
.task input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin: 0;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.task input[type="checkbox"]:hover { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.task input[type="checkbox"]:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--green-soft); }
.task input[type="checkbox"]::after {
  content: "";
  width: 5px;
  height: 10px;
  margin-top: -2px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
  opacity: 0;
}
.task input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border-color: var(--green);
}
.task input[type="checkbox"]:checked::after { opacity: 1; }

.badge {
  display: inline-block;
  margin-right: 8px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  /* 優先度の色と混ざらないよう、未完了はグレーで控えめに */
  background: var(--surface-muted);
  color: var(--text-muted);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.task.done .badge { background: var(--green-soft); color: var(--green-dark); box-shadow: none; }

/* 削除ボタン（アイコン） */
.delete-btn {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-faint);
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.delete-btn svg { width: 18px; height: 18px; }
.delete-btn:hover, .delete-btn:focus-visible { background: var(--red-soft); color: var(--red); outline: none; }
/* マウス操作の環境ではホバー時のみ表示 */
@media (hover: hover) {
  .delete-btn { opacity: 0; }
  .task:hover .delete-btn, .delete-btn:focus-visible { opacity: 1; }
}

/* ---- ダッシュボード：最新の振り返り ---- */
.latest-review {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: -8px 0 24px;
  padding: 18px 22px;
  background: linear-gradient(120deg, #fff 0%, #fff 55%, var(--pink-soft) 100%);
  border: 1px solid var(--border);
  border-left: 5px solid var(--pink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.latest-review-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--pink-soft);
  color: var(--pink);
}
.latest-review-icon svg { width: 24px; height: 24px; }
.latest-review-body { flex: 1; min-width: 0; }
.latest-review-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.latest-review-text {
  margin: 4px 0 0;
  font-weight: 500;
  white-space: pre-wrap;
  word-break: break-word;
  /* 長いコメントは2行で省略 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest-review-text.is-empty { font-weight: 400; color: var(--text-faint); }
.latest-review-link {
  flex-shrink: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.25);
  transition: filter 0.15s;
}
.latest-review-link:hover { filter: brightness(1.08); }

.week-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--pink-soft);
  color: var(--pink-dark);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ---- 週次の振り返り ---- */
html { scroll-behavior: smooth; }
.panel-review {
  --c: var(--pink);
  --c-dark: var(--pink-dark);
  --c-soft: var(--pink-soft);
  margin-top: 24px;
  scroll-margin-top: 16px;
}
.review-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 32px;
  align-items: start;
}
/* 2カラム時は右側の見出しに区切り線を付けない */
.review-columns > div > .panel-title:first-child { margin-top: 0; padding-top: 0; border-top: none; }

.week-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  background: var(--pink-soft);
  border-radius: var(--radius-sm);
}
.week-nav {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: var(--surface);
  color: var(--pink-dark);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, color 0.15s;
}
.week-nav:hover:not(:disabled) { background: var(--pink); color: #fff; }
.week-nav:disabled { opacity: 0.35; cursor: not-allowed; }
.week-label {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 700;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.week-label .week-tag { background: var(--pink); color: #fff; }

.this-week-btn {
  display: block;
  margin: 8px 0 0 auto;
  padding: 0;
  border: none;
  background: none;
  color: var(--pink-dark);
  font-size: 0.8rem;
  font-weight: 600;
}
.this-week-btn:hover { text-decoration: underline; }

.review-form { margin-top: 12px; }
.review-form textarea { min-height: 150px; line-height: 1.7; }
.review-form .form-actions { justify-content: space-between; align-items: center; gap: 12px; }
.review-status { font-size: 0.78rem; color: var(--text-faint); }

.review {
  border-left: 5px solid var(--pink-soft) !important;
}
.review.is-selected {
  border-color: var(--pink) !important;
  background: #fff8fc;
  box-shadow: 0 0 0 3px var(--pink-soft);
}
.review-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.review-week {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.review-comment {
  margin: 6px 0 4px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.edit-btn {
  flex-shrink: 0;
  padding: 3px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.edit-btn:hover { background: var(--pink); border-color: var(--pink); color: #fff; }

/* ---- レスポンシブ ---- */
@media (max-width: 820px) {
  .dashboard { grid-template-columns: repeat(2, 1fr); }
  .columns { grid-template-columns: 1fr; }
  .review-columns { grid-template-columns: 1fr; gap: 0; }
  .review-columns > div + div > .panel-title:first-child {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px dashed var(--border-strong);
  }
}
@media (max-width: 600px) {
  main { padding: 20px 16px 48px; }
  .app-header { flex-wrap: wrap; }
  .dashboard { gap: 10px; }
  .stat { gap: 12px; padding: 16px 14px 14px; }
  .stat-icon { width: 36px; height: 36px; border-radius: 10px; }
  .stat-icon svg { width: 19px; height: 19px; }
  .stat-value { font-size: 1.55rem; }
  .panel { padding: 18px; }
  .latest-review { flex-wrap: wrap; align-items: flex-start; padding: 16px; gap: 12px; }
  .latest-review-icon { width: 36px; height: 36px; border-radius: 10px; }
  .latest-review-icon svg { width: 19px; height: 19px; }
  /* 本文はアイコンの横いっぱいに広げ、ボタンは次の行の右端へ */
  .latest-review-body { flex-basis: calc(100% - 48px); }
  .latest-review .week-tag { white-space: normal; }
  .latest-review-link { margin-left: auto; }
}
