/* ===== デザイントークン ===== */
:root {
  --bg: #f1f5f9;
  --bg-gradient: radial-gradient(1200px 600px at 10% -10%, #eef2ff 0%, transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, #ecfeff 0%, transparent 55%), #f1f5f9;
  --surface: #ffffff;
  --text: #0f172a;
  --text-sub: #64748b;
  --muted: #94a3b8;
  --border: #e9edf3;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 14px 40px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Meiryo", system-ui, -apple-system,
    "Segoe UI", sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
}

/* ===== ヘッダー ===== */
.app-header {
  background: transparent;
  color: var(--text);
  padding: 32px 24px 8px;
  max-width: 1040px;
  margin: 0 auto;
}

.app-header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header .subtitle {
  margin: 6px 0 0;
  color: var(--text-sub);
  font-size: 0.9rem;
}

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

/* ===== ダッシュボード ===== */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 32px;
}

.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-sub);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: 0.78rem;
  margin-top: 6px;
  color: var(--muted);
}

/* 未完了タスクカード：主役として目立たせる */
.stat-card.pending {
  color: #fff;
  border: none;
  background: linear-gradient(135deg, #fb923c 0%, #f43f5e 100%);
  box-shadow: 0 10px 28px rgba(244, 63, 94, 0.32);
}

.stat-card.pending:hover {
  box-shadow: 0 14px 34px rgba(244, 63, 94, 0.42);
}

.stat-card.pending .stat-label {
  color: rgba(255, 255, 255, 0.92);
}

.stat-card.pending .stat-value {
  color: #fff;
  font-size: 2.8rem;
}

.stat-card.pending .stat-sub {
  color: rgba(255, 255, 255, 0.88);
}

/* 未完了が1件以上：やわらかく脈打つ */
.stat-card.pending.has-pending {
  animation: glow 2.4s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 10px 28px rgba(244, 63, 94, 0.30);
  }
  50% {
    box-shadow: 0 14px 36px rgba(244, 63, 94, 0.55);
  }
}

/* 未完了が0件：落ち着いた達成カラー */
.stat-card.pending.all-clear {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 10px 28px rgba(16, 185, 129, 0.3);
  animation: none;
}

/* ===== 最新の振り返り（ダッシュボード） ===== */
.latest-reflection {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 32px;
  box-shadow: 0 10px 28px rgba(99, 102, 241, 0.3);
}

.lr-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.lr-icon {
  font-size: 1.1rem;
}

.lr-title {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.lr-week {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: 999px;
}

.lr-comment {
  margin: 0;
  font-size: 1rem;
  line-height: 1.7;
  white-space: pre-wrap;
  opacity: 0.97;
}

/* 未記録のときは落ち着いたトーン */
.latest-reflection:not(.has-data) {
  background: var(--surface);
  color: var(--text-sub);
  border: 1px dashed #d8def0;
  box-shadow: var(--shadow-sm);
}

.latest-reflection:not(.has-data) .lr-title {
  color: var(--text);
}

/* ===== 週次振り返りパネル ===== */
.reflection-panel {
  margin-top: 22px;
}

.reflection-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.week-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-sub);
}

.week-field input[type="week"] {
  padding: 10px 13px;
  border: 1px solid #dfe5ec;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fbfcfe;
  max-width: 220px;
}

.week-field input[type="week"]:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.badge.week-badge {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

/* ===== 2カラム ===== */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

@media (max-width: 1040px) {
  .dashboard {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  margin: 0 0 18px;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

/* ===== フォーム ===== */
.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}

.form input,
.form textarea {
  padding: 11px 13px;
  border: 1px solid #dfe5ec;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #fbfcfe;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.form input::placeholder,
.form textarea::placeholder {
  color: var(--muted);
}

.form input:focus,
.form textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form textarea {
  resize: vertical;
  min-height: 72px;
}

.form button {
  padding: 11px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.form button:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.form button:active {
  transform: translateY(1px);
}

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

.list li {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: #fff;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.list li:hover {
  border-color: #d8def0;
  box-shadow: var(--shadow-sm);
}

.memo-title {
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 0.98rem;
}

.memo-content {
  white-space: pre-wrap;
  font-size: 0.9rem;
  color: #334155;
}

.meta {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

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

.task-title {
  flex: 1;
  font-size: 0.95rem;
}

.task-done .task-title {
  text-decoration: line-through;
  color: var(--muted);
}

.task-done {
  background: #fafbfc;
}

/* カスタムチェックボックス */
.item-head input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  flex: 0 0 auto;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.item-head input[type="checkbox"]:hover {
  border-color: var(--accent);
}

.item-head input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.item-head input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 4px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* バッジ */
.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: #e8f5ee;
  color: #15803d;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge.pending {
  background: #fef3e2;
  color: #c2410c;
}

/* ボタン（小） */
.btn-sm {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-delete {
  color: var(--muted);
}

.btn-delete:hover {
  background: #fdecec;
  color: #dc2626;
}

/* 空状態 */
.empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 28px 12px;
  border: 1px dashed #dde3ee;
  border-radius: var(--radius-sm);
  background: #fbfcfe;
}
