/* ---------- デザイントークン ---------- */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --border: #e7e4de;
  --border-strong: #d6d2ca;
  --text: #1d1c1a;
  --text-2: #5f5c56;
  --text-3: #9a968e;
  --accent: #3d5afe;
  --accent-soft: rgba(61, 90, 254, 0.1);
  --accent-ink: #ffffff;
  --success: #2f8f5b;
  --danger: #c4442f;
  --danger-soft: rgba(196, 68, 47, 0.08);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(29, 28, 26, 0.04), 0 4px 16px rgba(29, 28, 26, 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1c1c1a;
    --surface-2: #222220;
    --border: #2e2d2a;
    --border-strong: #3d3c38;
    --text: #efede8;
    --text-2: #b3afa7;
    --text-3: #7b776f;
    --accent: #7c8fff;
    --accent-soft: rgba(124, 143, 255, 0.14);
    --accent-ink: #10121f;
    --success: #5cc48a;
    --danger: #ef7a66;
    --danger-soft: rgba(239, 122, 102, 0.1);
    --shadow: none;
    color-scheme: dark;
  }
}

/* ---------- ベース ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.shell { max-width: 1080px; margin: 0 auto; padding: 40px 24px 64px; }

/* ---------- ヘッダー ---------- */
.topbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; }
.eyebrow { margin: 0 0 4px; font-size: 13px; color: var(--text-3); letter-spacing: 0.04em; }
.topbar h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.brand {
  font-size: 12px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text-3); padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px;
}

/* ---------- ダッシュボード ---------- */
.dashboard {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 28px; overflow: hidden;
}
.stat { display: flex; flex-direction: column; gap: 2px; padding: 22px 24px; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat-label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.stat-value {
  font-size: 40px; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-note { font-size: 12px; color: var(--text-3); }
.stat-accent .stat-value { color: var(--accent); }
.stat-done .stat-value { color: var(--success); }
.progress { height: 4px; background: var(--border); border-radius: 999px; margin: 8px 0 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s ease; }

/* ---------- パネル ---------- */
.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 22px 8px;
}
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.count {
  font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; font-variant-numeric: tabular-nums;
}

/* ---------- 入力欄 ---------- */
.composer {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px; margin-bottom: 8px;
}
.composer-inline { flex-direction: row; align-items: center; }
.composer-inline input { flex: 1; min-width: 0; }
.composer-actions { display: flex; justify-content: flex-end; }
input, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 72px; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

button { font: inherit; cursor: pointer; border: none; }
.btn-primary {
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 14px;
  padding: 9px 18px; border-radius: 8px; white-space: nowrap; transition: filter .15s, transform .05s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-delete {
  background: transparent; color: var(--text-3); font-size: 12px; font-weight: 500;
  padding: 4px 10px; border-radius: 6px; opacity: 0; transition: opacity .15s, color .15s, background .15s;
  flex-shrink: 0;
}
.item:hover .btn-delete, .btn-delete:focus-visible { opacity: 1; }
.btn-delete:hover { color: var(--danger); background: var(--danger-soft); }
@media (hover: none) { .btn-delete { opacity: 1; } }

/* ---------- 一覧 ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.item { padding: 14px 4px; border-top: 1px solid var(--border); }
.list .item:first-child { border-top: none; }
.empty { text-align: center; color: var(--text-3); font-size: 14px; padding: 28px 0 20px; }
.meta { font-size: 12px; color: var(--text-3); margin-top: 4px; font-variant-numeric: tabular-nums; }

.memo-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.memo-title { font-weight: 600; font-size: 15px; word-break: break-word; }
.memo-body { white-space: pre-wrap; word-break: break-word; margin-top: 4px; font-size: 14px; color: var(--text-2); }

.task { display: flex; align-items: flex-start; gap: 12px; }
.task .content { flex: 1; min-width: 0; }
.task-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task .text { word-break: break-word; transition: color .2s; }
.task.done .text { text-decoration: line-through; color: var(--text-3); }

/* 丸いチェックボックス */
.check {
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
  width: 20px; height: 20px; margin: 2px 0 0; padding: 0; border-radius: 50%;
  border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer;
  display: grid; place-content: center; transition: background .15s, border-color .15s;
}
.check::after {
  content: ""; width: 9px; height: 5px; border-left: 2px solid var(--accent-ink); border-bottom: 2px solid var(--accent-ink);
  transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform .15s;
}
.check:hover { border-color: var(--accent); }
.check:checked { background: var(--success); border-color: var(--success); }
.check:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); border-color: #fff; }
.check:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.badge { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; line-height: 1.6; }
.badge.todo { color: var(--accent); background: var(--accent-soft); }
.badge.done { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); }

/* ---------- ダッシュボード：最新の振り返り ---------- */
.latest-review {
  grid-column: 1 / -1; display: flex; flex-direction: column; gap: 2px;
  padding: 16px 24px 18px; border-top: 1px solid var(--border);
  color: inherit; text-decoration: none; transition: background .15s;
}
.latest-review:hover { background: var(--surface-2); }
.latest-week { font-size: 12px; color: var(--accent); font-weight: 600; }
.latest-comment {
  margin: 2px 0 0; font-size: 14px; color: var(--text-2); white-space: pre-wrap; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.latest-review.is-empty .latest-comment { color: var(--text-3); }

/* ---------- 週次の振り返り ---------- */
.review-panel { margin-top: 24px; scroll-margin-top: 24px; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
.week-nav { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.week-label { flex: 1; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.week-tag { display: block; font-size: 11px; font-weight: 500; color: var(--text-3); min-height: 1.4em; }
.btn-icon {
  width: 32px; height: 32px; border-radius: 8px; background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border); font-size: 18px; line-height: 1; transition: background .15s;
}
.btn-icon:hover:not(:disabled) { background: var(--border); }
.btn-icon:disabled { opacity: .35; cursor: default; }
.btn-ghost {
  background: transparent; color: var(--accent); font-size: 13px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px;
}
.btn-ghost:hover { background: var(--accent-soft); }
.week-stats { text-wrap: balance; margin: 0 0 10px; font-size: 12px; color: var(--text-3); text-align: center; }
.saved-note { margin-right: auto; align-self: center; font-size: 12px; color: var(--text-3); }
.sub-head { margin: 4px 0 8px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.review-item.is-current { background: var(--accent-soft); border-radius: 8px; padding-left: 10px; padding-right: 10px; border-top-color: transparent; }
.review-item.is-current + .item { border-top-color: transparent; }
.review-week { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.item-actions { display: flex; gap: 2px; flex-shrink: 0; }
.item-actions button { white-space: nowrap; }
.review-week { min-width: 0; }
.btn-edit {
  background: transparent; color: var(--text-3); font-size: 12px; font-weight: 500;
  padding: 4px 10px; border-radius: 6px; transition: color .15s, background .15s;
}
.btn-edit:hover { color: var(--accent); background: var(--accent-soft); }

/* 追加時のふわっと表示 */
.item.fresh { animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- レスポンシブ ---------- */
@media (max-width: 820px) {
  .columns, .review-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .shell { padding: 24px 16px 48px; }
  .topbar h1 { font-size: 23px; }
  .brand { display: none; }
  .stat { padding: 16px 14px; }
  /* スマホでは 2×2 に並べる */
  .dashboard { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { border-left: none; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
  .latest-review { padding: 14px 14px 16px; }
  .stat-value { font-size: 30px; }
  .panel { padding: 18px 16px 6px; }
}
