/* ===========================================================================
   カラーとトークン
   =========================================================================== */
:root {
  --bg: #f5f6fa;
  --bg-tint-a: rgba(99, 102, 241, 0.10);
  --bg-tint-b: rgba(14, 165, 233, 0.08);

  --surface: #ffffff;
  --surface-sunken: #f4f6fb;
  --surface-raised: #ffffff;

  --border: #e6e9f1;
  --border-strong: #d3dae6;

  --text: #141c2b;
  --text-soft: #46536a;
  --muted: #6b7789;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --on-accent: #ffffff;
  --accent-soft: #eef0ff;
  --accent-line: #c7cbfb;

  --done: #0f9d70;
  --done-soft: #e9f6f0;
  --done-line: #b6e0cd;

  --danger: #d93b3b;
  --danger-soft: #fdeceb;
  --danger-line: #f0c2be;

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 12px 28px -18px rgba(16, 24, 40, 0.35);
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.22);

  --ease: 0.16s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1220;
    --bg-tint-a: rgba(99, 102, 241, 0.20);
    --bg-tint-b: rgba(14, 165, 233, 0.12);

    --surface: #161c2c;
    --surface-sunken: #1c2436;
    --surface-raised: #1f2839;

    --border: #2a3348;
    --border-strong: #3a4560;

    --text: #e8edf7;
    --text-soft: #c2cbdb;
    --muted: #94a2b8;

    --accent: #8b93ff;
    --accent-hover: #a3a9ff;
    /* 明るい紫の上は白より濃い文字のほうが読みやすい */
    --on-accent: #10142a;
    --accent-soft: #23294a;
    --accent-line: #3f4785;

    --done: #46c79b;
    --done-soft: #14312a;
    --done-line: #2c5f4e;

    --danger: #f08a84;
    --danger-soft: #35201f;
    --danger-line: #6b3a37;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -18px rgba(0, 0, 0, 0.8);
    --ring: 0 0 0 3px rgba(139, 147, 255, 0.3);
  }
}

* { box-sizing: border-box; }

/* ===========================================================================
   ベース
   =========================================================================== */
body {
  margin: 0;
  padding: 0 20px 64px;
  min-height: 100vh;
  font-family: "Segoe UI Variable Text", "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background-color: var(--bg);
  /* 上部にごく薄い色みを置いて、平坦さをなくす */
  background-image:
    radial-gradient(70rem 34rem at 12% -12%, var(--bg-tint-a), transparent 60%),
    radial-gradient(58rem 30rem at 92% -6%, var(--bg-tint-b), transparent 62%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { letter-spacing: -0.015em; }

/* ===========================================================================
   ヘッダー
   =========================================================================== */
.site-header {
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 0 24px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(145deg, #6366f1, #4338ca);
  box-shadow: 0 6px 16px -6px rgba(67, 56, 202, 0.7);
}
.brand-text h1 { margin: 0; font-size: 24px; font-weight: 650; }
.lead { margin: 1px 0 0; color: var(--muted); font-size: 13.5px; }

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

/* ===========================================================================
   ダッシュボード
   =========================================================================== */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 18px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  transition: transform var(--ease), box-shadow var(--ease);
}
.stat:hover { transform: translateY(-1px); }
/* カード上端の細い色ライン */
.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-line), transparent 70%);
}
.stat-accent { background: var(--accent-soft); border-color: var(--accent-line); }
.stat-accent::before { background: linear-gradient(90deg, var(--accent), transparent 75%); }

.stat-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.stat-value {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-unit { font-size: 12px; color: var(--muted); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-memo { background: #6366f1; }
.dot-task { background: #0ea5e9; }
.dot-open { background: #f59e0b; }
.dot-done { background: var(--accent); }
.dot-review { background: var(--done); }

/* 最新の振り返り（ダッシュボード内で横いっぱいに置く） */
.latest-review { grid-column: 1 / -1; gap: 6px; }
.latest-review::before { background: linear-gradient(90deg, var(--done-line), transparent 70%); }
.latest-week {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.latest-comment {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  /* 長い振り返りはダッシュボード上では3行までにする */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest-meta { margin-top: 2px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.latest-empty { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* ===========================================================================
   メッセージ
   =========================================================================== */
.message {
  margin: 0 0 18px;
  padding: 11px 15px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-line);
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}

/* ===========================================================================
   パネル
   =========================================================================== */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel-wide { margin-top: 18px; }
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.chip {
  margin-left: auto;
  min-width: 26px;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* ===========================================================================
   フォーム
   =========================================================================== */
.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 15px;
  margin-bottom: 18px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row input { flex: 1; }
.hint { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.form-actions { display: flex; gap: 8px; }

input, textarea {
  font: inherit;
  width: 100%;
  padding: 9px 12px;
  color: inherit;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}
textarea { resize: vertical; min-height: 70px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.75; }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

/* ===========================================================================
   ボタン
   =========================================================================== */
button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  white-space: nowrap;
  transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 6px 14px -8px rgba(79, 70, 229, 0.9);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-small { padding: 5px 11px; font-size: 12.5px; }
.btn-ghost {
  background: var(--surface-raised);
  color: var(--text-soft);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text); }
.btn-danger {
  background: transparent;
  color: var(--muted);
  border-color: var(--border-strong);
}
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }

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

/* パネルより一段沈んだ面にして、項目の輪郭が分かるようにする */
.item {
  position: relative;
  padding: 13px 15px 12px 17px;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
}
/* 左端の色帯（角丸に沿わせるため疑似要素で描く） */
.item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.item:hover { border-color: var(--accent-line); transform: translateX(1px); }

.item-head { display: flex; align-items: flex-start; gap: 10px; }
.item-title { flex: 1; font-weight: 650; word-break: break-word; letter-spacing: -0.005em; }
.item-body {
  margin: 9px 0 0;
  padding: 9px 11px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.item-meta {
  display: flex;
  align-items: center;
  gap: 6px 12px;
  flex-wrap: wrap;
  margin-top: 9px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* 完了したタスクは緑寄りにして、一目で区別できるようにする */
/* 振り返りはメモ・タスクと区別できるよう緑の帯にする */
.item-review::before { background: var(--done); }
.item-review .item-title { font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 9px; }
.tag-inline { font-weight: 700; }

.item.done { background: var(--done-soft); border-color: var(--done-line); }
.item.done::before { background: var(--done); }
.item.done .item-title { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--muted); font-weight: 600; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: var(--surface-raised);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-open { color: var(--accent); }
.badge-done { color: var(--done); }

.actions { display: flex; gap: 6px; }

/* 空のときの表示 */
.empty {
  padding: 22px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-sunken);
}

/* ===========================================================================
   レスポンシブ
   =========================================================================== */
@media (max-width: 900px) {
  .columns { grid-template-columns: 1fr; }
  .dashboard { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  body { padding: 0 14px 48px; }
  .site-header { padding: 28px 0 20px; }
  .dashboard { grid-template-columns: 1fr; }
  .stat-value { font-size: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
