:root {
  color-scheme: light dark;

  --bg: #f6f7fb;
  --bg-glow: rgba(99, 102, 241, 0.10);
  --surface: #ffffff;
  --input-bg: #f7f8fc;
  --item-bg: #f1f3fa;          /* 一覧のカード。白い枠より一段濃くする */
  --item-hover: #e9edf8;
  --item-border: #dde2ee;
  --border: #e6e8ef;
  --border-strong: #ccd2e0;
  --text: #1b2130;
  --muted: #6d7688;
  --faint: #939bad;
  --accent: #5b5bd6;
  --accent-soft: #eeeefc;
  --danger: #d6455c;
  --done: #2e9c6c;
  --done-bg: #e3f3ec;
  --shadow-sm: 0 1px 2px rgba(20, 26, 45, 0.05);
  --shadow-md: 0 8px 24px -12px rgba(20, 26, 45, 0.18);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1219;
    --bg-glow: rgba(129, 130, 245, 0.14);
    --surface: #171b24;
    --input-bg: #1b202b;
    --item-bg: #222836;
    --item-hover: #29303f;
    --item-border: #313a4b;
    --border: #262c39;
    --border-strong: #3c465a;
    --text: #e8ebf2;
    --muted: #a2abbe;
    --faint: #757e91;
    --accent: #8b8cf5;
    --accent-soft: #23253c;
    --danger: #f0708a;
    --done: #4cc38a;
    --done-bg: #1b3227;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 28px -14px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  padding: 40px 20px 72px;
  background: var(--bg);
  background-image:
    radial-gradient(60rem 26rem at 12% -8%, var(--bg-glow), transparent 65%),
    radial-gradient(46rem 22rem at 96% 4%, var(--bg-glow), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

.shell { max-width: 1000px; margin: 0 auto; }

/* ヘッダー ------------------------------------------------------------- */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}

.page-header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

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

.today {
  margin: 0;
  color: var(--faint);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ダッシュボード --------------------------------------------------------- */

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

.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px 18px;
  overflow: hidden;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.stat-value {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease;
}

.stat-unit { font-size: 0.78rem; color: var(--faint); margin-left: 4px; }

.stat-accent { border-color: color-mix(in srgb, var(--accent) 32%, var(--border)); }
.stat-accent .stat-value { color: var(--accent); }

.stat-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--accent-soft);
}

.stat-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.35s ease;
}

/* ダッシュボード内：最新の振り返り */

.latest-review {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 18px 16px;
}

.latest-review-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.latest-review-week {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.latest-review-body {
  margin: 4px 0 0;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.latest-review-body.is-empty { color: var(--faint); }

/* カード ---------------------------------------------------------------- */

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 20px;
}

.card-wide { margin-top: 18px; }

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.card-header h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.count-chip {
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.list-heading {
  margin: 22px 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--faint);
  letter-spacing: 0.1em;
}

/* フォーム -------------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: 9px; }
.form-inline { flex-direction: row; }
.form-inline input { flex: 1; }

.field-row { display: flex; align-items: center; gap: 10px; }
.field-label { font-size: 0.78rem; font-weight: 700; color: var(--muted); white-space: nowrap; }

input[type="text"], textarea, select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font: inherit;
  font-size: 0.94rem;
  color: inherit;
  background: var(--input-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

select {
  max-width: 280px;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}

input::placeholder, textarea::placeholder { color: var(--faint); }

input[type="text"]:focus, textarea:focus, select:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

textarea { resize: vertical; min-height: 76px; }

.hint { margin: -2px 0 2px; font-size: 0.76rem; color: var(--faint); }

button { font: inherit; cursor: pointer; border: none; border-radius: 10px; }

.btn-primary {
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow-sm);
  transition: filter 0.15s ease, transform 0.1s ease;
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }

.btn-primary: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; display: flex; flex-direction: column; gap: 10px; }

.item {
  position: relative;
  border: 1px solid var(--item-border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--item-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
  animation: rise 0.22s ease both;
}

.item:hover {
  background: var(--item-hover);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

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

@media (prefers-reduced-motion: reduce) {
  .item { animation: none; }
  * { transition-duration: 0.01ms !important; }
}

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

.item-title {
  flex: 1;
  font-weight: 600;
  word-break: break-word;
  transition: color 0.2s ease;
}

.item-body {
  margin: 7px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  color: var(--muted);
}

.item-meta {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.item-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

/* 振り返り一覧は週のラベルを目立たせる */
.list-review .item { border-left: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }
.list-review .item-title { color: var(--accent); font-variant-numeric: tabular-nums; }
.list-review .item-body { color: var(--text); }

/* タスクの完了チェック */

.check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  padding: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: transparent;
  display: grid;
  place-items: center;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.check svg { width: 11px; height: 11px; stroke: currentColor; stroke-width: 2.6; fill: none; }
.check:hover { border-color: var(--done); color: color-mix(in srgb, var(--done) 45%, transparent); }

.item.done { background: var(--done-bg); border-color: color-mix(in srgb, var(--done) 30%, var(--item-border)); }
.item.done:hover { background: color-mix(in srgb, var(--done) 12%, var(--done-bg)); }
.item.done .check { background: var(--done); border-color: var(--done); color: #fff; }
.item.done .item-title { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 55%, transparent); }

.icon-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--faint);
  border-radius: 8px;
  opacity: 0.8;
  transition: color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.icon-btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; }
.item:hover .icon-btn { opacity: 1; }
.icon-btn:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.icon-btn:last-child:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

.empty {
  margin: 4px 0 0;
  padding: 22px 12px;
  text-align: center;
  color: var(--faint);
  font-size: 0.85rem;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
}

.error {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
  border-radius: 10px;
  padding: 11px 14px;
  margin: 0 0 18px;
  font-size: 0.88rem;
  font-weight: 600;
}

/* レスポンシブ ----------------------------------------------------------- */

@media (max-width: 780px) {
  body { padding: 28px 16px 56px; }
  .columns { grid-template-columns: 1fr; }
  .dashboard { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stat { padding: 13px 14px 15px; }
  .stat-value { font-size: 1.7rem; }
  .page-header { align-items: flex-start; flex-direction: column; gap: 6px; }
  .icon-btn { opacity: 1; }
  .field-row { flex-direction: column; align-items: stretch; gap: 6px; }
  select { max-width: none; }
}
