:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e6e8ec;
  --text: #1c2230;
  --text-2: #5b6474;
  --text-3: #8b93a1;
  --accent: #4f5bd5;
  --accent-hover: #414bc0;
  --accent-soft: #eef0fc;
  --success: #1f9d63;
  --success-soft: #e6f6ee;
  --warn: #d97706;
  --warn-soft: #fdf3e2;
  --danger: #dc4b4b;
  --danger-soft: #fdecec;
  --memo: #0ea5a4;
  --memo-soft: #e3f6f6;
  --review: #8b5cf6;
  --review-soft: #f1ebfe;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #171b23;
    --surface-2: #1d222c;
    --border: #2a303c;
    --text: #e8ebf1;
    --text-2: #a4acba;
    --text-3: #717a8a;
    --accent: #7c86f0;
    --accent-hover: #929bf4;
    --accent-soft: #252a4a;
    --success: #4cc38a;
    --success-soft: #16301f;
    --warn: #f0a93b;
    --warn-soft: #33260f;
    --danger: #f07474;
    --danger-soft: #3a1c1c;
    --memo: #3cc9c7;
    --memo-soft: #12302f;
    --review: #a98bfa;
    --review-soft: #2a2145;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ヘッダー */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
}
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.today { color: var(--text-2); font-size: .9rem; }

main { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; }

.greeting {
  margin: 0 0 20px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: .01em;
}

/* ダッシュボード */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-body { flex: 1; }
.stat-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
}
.stat-icon.memo { background: var(--memo-soft); color: var(--memo); }
.stat-icon.task { background: var(--accent-soft); color: var(--accent); }
.stat-icon.done { background: var(--success-soft); color: var(--success); }
.stat-icon.pending { background: var(--warn-soft); color: var(--warn); }
.stat-label { color: var(--text-2); font-size: .85rem; }
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-value small { font-size: .85rem; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.progress {
  margin-top: 8px;
  height: 6px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--success);
  border-radius: 99px;
  transition: width .4s ease;
}

/* レイアウト */
.columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.column { display: flex; flex-direction: column; gap: 20px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-title { margin: 0 0 14px; font-size: 1rem; font-weight: 700; }
.card-head .card-title { margin: 0; }
.pill {
  min-width: 26px;
  padding: 1px 9px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: .8rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

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

input[type="text"], textarea {
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface-2);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; min-height: 96px; }
input[type="text"]::placeholder, textarea::placeholder { color: var(--text-3); }
input[type="text"]:focus, textarea:focus {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  padding: 9px 18px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn:focus-visible, .icon-btn:focus-visible, .check:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 一覧 */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 14px 0; border-top: 1px solid var(--border); animation: fade-in .25s ease; }
.list > li:first-child { border-top: none; }

.empty {
  text-align: center;
  color: var(--text-3);
  padding: 28px 0 !important;
  font-size: .9rem;
}
.empty svg { display: block; margin: 0 auto 8px; opacity: .6; }

.memo-title { font-weight: 700; font-size: .98rem; }
.memo-body { white-space: pre-wrap; word-break: break-word; margin: 4px 0 6px; color: var(--text-2); font-size: .92rem; }
.date { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: .78rem; }

.task { display: flex; align-items: center; gap: 12px; }
.task-main { flex: 1; min-width: 0; }
.task-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-text { font-size: .95rem; word-break: break-word; transition: color .2s; }
.task.done .task-text { text-decoration: line-through; color: var(--text-3); }

.check {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  color: #fff;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.check:hover { border-color: var(--success); }
.check svg { opacity: 0; transition: opacity .15s; }
.task.done .check { background: var(--success); border-color: var(--success); }
.task.done .check svg { opacity: 1; }

.status {
  font-size: .72rem;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--warn-soft);
  color: var(--warn);
}
.task.done .status { background: var(--success-soft); color: var(--success); }

.icon-btn {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }

/* 最新の振り返り（ダッシュボード） */
.latest-review {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--review);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: -12px 0 28px;
  box-shadow: var(--shadow);
}
.latest-head { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; }
.latest-head > div:nth-child(2) { flex: 1; min-width: 160px; }
.latest-head .text-link { margin-left: auto; }
.latest-week { font-weight: 700; }
.latest-comment {
  margin: 10px 0 0;
  color: var(--text-2);
  font-size: .92rem;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest-comment.muted { color: var(--text-3); }
.stat-icon.review { background: var(--review-soft); color: var(--review); }
.text-link { color: var(--accent); font-size: .85rem; text-decoration: none; white-space: nowrap; }
.text-link:hover { text-decoration: underline; }

/* 週次の振り返り */
.reviews { margin-top: 4px; scroll-margin-top: 80px; }
.reviews-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.field-label { font-size: .85rem; color: var(--text-2); font-weight: 500; margin-bottom: -4px; }
.sub-title { margin: 0; font-size: .92rem; font-weight: 700; }
select {
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface-2);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-actions { align-items: center; gap: 12px; }
.form-hint { font-size: .8rem; color: var(--text-3); margin-right: auto; }

.review-item { display: flex; gap: 12px; }
.review-main { flex: 1; min-width: 0; }
.review-week { font-weight: 700; font-size: .95rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.review-comment { white-space: pre-wrap; word-break: break-word; margin: 4px 0 6px; color: var(--text-2); font-size: .92rem; }
.badge-now {
  font-size: .72rem;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--review-soft);
  color: var(--review);
}
.review-actions { display: flex; gap: 2px; align-self: flex-start; }
.icon-btn.edit-btn:hover { background: var(--accent-soft); color: var(--accent); }

/* トースト */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: .9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* レスポンシブ */
@media (max-width: 860px) {
  .columns, .reviews-grid { grid-template-columns: minmax(0, 1fr); }
  .dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .topbar-inner { padding: 12px 16px; }
  main { padding: 20px 16px 48px; }
  .greeting { font-size: 1.25rem; }
  .dashboard { grid-template-columns: 1fr; gap: 10px; }
  .stat { padding: 14px 16px; }
  .card { padding: 18px 16px; }
}
