:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e6e9f2;
  --text: #1b2333;
  --muted: #737d92;
  --faint: #99a2b5;

  --primary: #4f46e5;
  --primary-dark: #4038c9;
  --primary-soft: #eef1ff;

  --blue: #3b82f6;
  --blue-soft: #eaf2ff;
  --green: #0e9f6e;
  --green-soft: #e7f8f1;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --violet: #7c5cd6;
  --violet-soft: #f2eeff;
  --danger: #d64550;
  --danger-soft: #fdf0f1;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 28, 48, 0.04), 0 14px 30px -22px rgba(20, 28, 48, 0.5);
}

* { box-sizing: border-box; }

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

/* アイコン共通 */
.sprite { display: none; }

.icon {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.header {
  background: linear-gradient(120deg, #2e2a72 0%, #4f46e5 60%, #5b6ff0 100%);
  color: #fff;
  padding: 22px 24px;
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 24px;
}

.header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.header-sub {
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 18px 72px;
}

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

.dashboard {
  display: grid;
  /* 画面幅に応じて 4枚 → 2枚 → 1枚 に折り返す */
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

/* 未完了は「これから対応するもの」なので琥珀色、完了は緑で色分けする */
.stat-open { border-color: #f0dcbc; background: linear-gradient(180deg, #fffcf6, #fff); }
.stat-done { border-color: #c9e6d8; background: linear-gradient(180deg, #f7fdfa, #fff); }

.stat-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 21px;
}

.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-green { background: var(--green-soft); color: var(--green); }
.tone-amber { background: var(--amber-soft); color: var(--amber); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }

.stat-text { display: flex; flex-direction: column; line-height: 1.25; }

.stat-label {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

.latest {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: linear-gradient(180deg, #fbfaff, #fff);
  border: 1px solid #e4dcfa;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 26px;
}

.latest-body { min-width: 0; }

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

.latest-label {
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.latest-week {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

.latest-text {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: #4d5768;
  white-space: pre-wrap;
  word-break: break-word;
  /* 長い振り返りは3行までにして、続きは一覧で読む */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

/* ---------- パネル ---------- */

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

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

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

.panel-head-list {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.panel-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 17px;
}

.panel-wide { margin-top: 20px; }

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.pill {
  margin-left: auto;
  background: #f1f3f8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 2px 11px;
  border-radius: 999px;
}

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

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

.form input,
.form textarea {
  width: 100%;
  padding: 11px 13px;
  background: #fbfcfe;
  border: 1px solid #d9dfeb;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: inherit;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

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

.form input:focus,
.form textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

/* 対象週の指定 */
.field-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.field { display: flex; align-items: center; gap: 8px; }

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.field-label .icon { font-size: 15px; }

.field input[type="date"] {
  width: auto;
  padding: 8px 11px;
  font-variant-numeric: tabular-nums;
}

.week-hint {
  font-size: 12.5px;
  color: var(--faint);
}

.btn-primary {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 14px -8px rgba(79, 70, 229, 0.9);
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn-primary .icon { font-size: 17px; stroke-width: 2.2; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: translateY(1px); box-shadow: none; }

/* ---------- 一覧 ---------- */

.list { list-style: none; margin: 0; padding: 0; }

.list li {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 15px;
  margin-bottom: 10px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.list li:hover {
  border-color: #d3daea;
  box-shadow: 0 8px 18px -14px rgba(20, 28, 48, 0.6);
}

.list li:last-child { margin-bottom: 0; }

.item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.item-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.item-title {
  font-weight: 600;
  font-size: 14.5px;
  word-break: break-word;
}

.item-body {
  margin: 7px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #4d5768;
  font-size: 13.5px;
}

.item-meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--faint);
}

.item-meta .icon { font-size: 13px; margin-right: 3px; vertical-align: -2px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge .icon { font-size: 13px; margin: 0; stroke-width: 2.4; }
.badge-done { background: var(--green-soft); color: var(--green); }
.badge-open { background: var(--amber-soft); color: var(--amber); }

.done { background: #fbfcfd; }
.done .item-title { text-decoration: line-through; color: var(--faint); }

/* 操作ボタン */
.actions { display: flex; gap: 6px; flex-shrink: 0; }

.actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  color: var(--muted);
  background: #fff;
  border: 1px solid #dde2ed;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.actions button .icon { font-size: 14px; }

.actions .toggle:hover { background: var(--green-soft); border-color: #b7e4d1; color: var(--green); }
.actions .edit:hover { background: var(--primary-soft); border-color: #cdd0f7; color: var(--primary); }
.actions .danger:hover { background: var(--danger-soft); border-color: #f0c8cc; color: var(--danger); }

/* 一覧の中での編集 */
.list li.editing {
  border-color: #c9cdf5;
  background: #fcfbff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.09);
}

.edit-form {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.edit-form textarea {
  width: 100%;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #d9dfeb;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.65;
  color: inherit;
  resize: vertical;
}

.edit-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

.edit-actions { display: flex; align-items: center; gap: 8px; }

.btn-sm {
  align-self: auto;
  padding: 7px 16px;
  font-size: 12.5px;
}

.btn-sm .icon { font-size: 15px; }

/* 空の状態 */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 0;
  color: var(--faint);
  font-size: 13.5px;
  border: 1px dashed #dfe4ee;
  border-radius: 12px;
  background: #fbfcfe;
}

.empty .icon { font-size: 26px; stroke-width: 1.5; }

/* ---------- トースト ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #232a3a;
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: 0 12px 30px -12px rgba(20, 28, 48, 0.7);
  animation: toast-in 0.18s ease-out;
}

.toast .icon { font-size: 16px; stroke-width: 2.2; }

/* display:flex が hidden 属性を打ち消さないようにする */
.toast[hidden] { display: none; }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

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

@media (max-width: 760px) {
  .columns { grid-template-columns: 1fr; }
  .stat { padding: 13px 15px; }
  .stat-value { font-size: 24px; }
}
