:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #94a3b8;
  --line: #e2e8f0;

  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --blue-line: #bfdbfe;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --green-line: #bbf7d0;
  --amber: #f59e0b;
  --orange: #f97316;
  --rose: #e11d48;
  --rose-soft: #fff1f2;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans JP", -apple-system, "Hiragino Kaku Gothic ProN", "Segoe UI", sans-serif;
  background:
    radial-gradient(1200px 600px at 100% -10%, #e0e7ff 0%, rgba(224, 231, 255, 0) 55%),
    radial-gradient(900px 500px at -10% 0%, #dcfce7 0%, rgba(220, 252, 231, 0) 50%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== ヘッダー ===== */
.app-header {
  background: linear-gradient(120deg, #0f172a 0%, #1e293b 55%, #334155 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  font-size: 2rem;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  backdrop-filter: blur(4px);
}

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

.subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 400;
}

/* ===== レイアウト ===== */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px;
}

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

.stat {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

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

.stat-icon {
  font-size: 1.5rem;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex-shrink: 0;
}

.stat-memo .stat-icon { background: var(--blue-soft); }
.stat-task .stat-icon { background: var(--green-soft); }
.stat-undone .stat-icon { background: #fff7ed; }

.stat-num {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--ink-faint);
  font-weight: 500;
}

/* 未完了タスクの強調 */
.stat-undone {
  border-color: #fed7aa;
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 100%);
}
.stat-undone .stat-num { color: var(--orange); }
.stat-undone .stat-label { color: #c2410c; font-weight: 700; }

/* 未完了が1件以上あるとき、さらに強調 */
.stat-undone.alert {
  border-color: var(--rose);
  background: linear-gradient(180deg, var(--rose-soft) 0%, #ffffff 100%);
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.08), var(--shadow-sm);
}
.stat-undone.alert .stat-icon {
  background: var(--rose-soft);
  animation: pulse 1.8s ease-in-out infinite;
}
.stat-undone.alert .stat-num {
  color: var(--rose);
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(225, 29, 72, 0); }
}

/* ===== 最新の振り返りバナー ===== */
.latest-review {
  background: linear-gradient(120deg, #faf5ff 0%, #ffffff 70%);
  border: 1px solid #e9d5ff;
  border-left: 5px solid #a855f7;
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}

.latest-review-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.latest-review-icon { font-size: 1.1rem; }

.latest-review-title {
  font-weight: 700;
  color: #7e22ce;
  font-size: 0.95rem;
}

.latest-review-week {
  font-size: 0.78rem;
  font-weight: 700;
  color: #9333ea;
  background: #f3e8ff;
  padding: 2px 10px;
  border-radius: 999px;
}

.latest-review-comment {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.latest-review.has-review .latest-review-comment {
  color: var(--ink);
}

/* ===== パネル ===== */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}

/* パネル上端のアクセントライン */
.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}
.memo-panel::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.task-panel::before { background: linear-gradient(90deg, #16a34a, #4ade80); }
.review-panel::before { background: linear-gradient(90deg, #a855f7, #c084fc); }

/* 振り返りパネルは横幅いっぱい（メモ・タスクの下） */
.review-panel { margin-top: 22px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.count-pill {
  font-size: 0.78rem;
  font-weight: 700;
  min-width: 26px;
  text-align: center;
  padding: 3px 10px;
  border-radius: 999px;
}
.memo-panel .count-pill { background: var(--blue-soft); color: var(--blue); }
.task-panel .count-pill { background: var(--green-soft); color: var(--green); }
.review-panel .count-pill { background: #f3e8ff; color: #9333ea; }

/* ===== 入力フォーム ===== */
.add-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px dashed var(--line);
}

.add-form input,
.add-form textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  background: #fafafa;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.add-form input:focus,
.add-form textarea:focus {
  outline: none;
  background: #fff;
}
.memo-panel .add-form input:focus,
.memo-panel .add-form textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.task-panel .add-form input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}
.review-panel .add-form input:focus,
.review-panel .add-form textarea:focus {
  border-color: #a855f7;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.14);
}

/* 振り返りフォームの「対象の週」ラベル */
.field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.field-label input[type="week"] {
  font-weight: 400;
  max-width: 220px;
}

.form-hint {
  margin: 0;
  font-size: 0.74rem;
  color: var(--ink-faint);
}

.review-panel .add-form button {
  background: #9333ea;
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.25);
}

.add-form button {
  align-self: flex-start;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.add-form button:active { transform: translateY(1px); }

.memo-panel .add-form button {
  background: var(--blue);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}
.task-panel .add-form button {
  background: var(--green);
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.25);
}
.add-form button:hover { opacity: 0.92; }

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

.card {
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.memo-card { border-left: 4px solid #3b82f6; }
.task-card { border-left: 4px solid #22c55e; }
.review-card { border-left: 4px solid #a855f7; }

.review-week {
  font-weight: 700;
  color: #7e22ce;
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.card-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--ink);
}

.card-body {
  white-space: pre-wrap;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.card-meta {
  font-size: 0.74rem;
  color: var(--ink-faint);
  margin-top: 8px;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ===== タスク ===== */
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.task-main { flex: 1; min-width: 0; }
.task-text { font-weight: 500; }

/* 未完了タスクを強調 */
.task-card.todo {
  border-left: 5px solid var(--orange);
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 60%);
}
.task-card.todo .task-text {
  font-weight: 700;
  color: #9a3412;
}

/* 完了タスクは控えめ */
.task-card.done {
  background: #f8fafc;
  border-left-color: #cbd5e1;
}
.task-card.done .task-text {
  text-decoration: line-through;
  color: var(--ink-faint);
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 9px;
  border-radius: 999px;
  margin-left: 6px;
  font-weight: 700;
  vertical-align: middle;
}
.badge.done { background: #e2e8f0; color: var(--ink-faint); }
.badge.todo { background: #ffedd5; color: #9a3412; }

/* ===== ボタン ===== */
.btn {
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  color: #fff;
  transition: transform 0.12s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: translateY(1px); }

.btn-toggle { background: #10b981; }
.btn-edit { background: #fff; color: var(--amber); border: 1px solid #fcd34d; }
.btn-delete { background: #fff; color: var(--rose); border: 1px solid #fecdd3; }
.btn-save { background: var(--blue); }
.btn-cancel { background: #fff; color: var(--ink-soft); border: 1px solid var(--line); }

/* ===== 編集フォーム ===== */
.card.editing {
  background: #fffef5;
  border-left-color: var(--amber) !important;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}

.edit-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  margin-bottom: 8px;
  resize: vertical;
  background: #fff;
}
.edit-input:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

/* ===== 空状態 ===== */
.empty {
  color: var(--ink-faint);
  font-size: 0.9rem;
  text-align: center;
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

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