:root {
  --canvas: #f5f7fb;
  --canvas-tint: #eef1f9;
  --panel: #ffffff;
  --panel-border: rgba(24, 32, 56, 0.08);

  --text: #1b2136;
  --muted: #78819b;

  --accent: #4f5bd5;
  --accent-hover: #4450c4;
  --accent-soft: #eef0ff;
  --accent-ring: rgba(79, 91, 213, 0.22);

  --item-bg: #fafbfe;
  --item-border: rgba(24, 32, 56, 0.09);
  --item-hover: #ffffff;

  --done-bg: #f2f4f8;
  --done-text: #8a92a8;

  --ok-bg: #e6f6ec;
  --ok-text: #1f7a45;
  --warn-bg: #fdf0e2;
  --warn-text: #9a5a17;
  --danger: #d0453d;

  --shadow-sm: 0 1px 2px rgba(24, 32, 56, 0.05);
  --shadow-md: 0 1px 2px rgba(24, 32, 56, 0.05), 0 10px 26px -18px rgba(24, 32, 56, 0.5);
  --shadow-lg: 0 2px 6px rgba(24, 32, 56, 0.07), 0 18px 40px -24px rgba(24, 32, 56, 0.55);

  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 15% -10%, #ffffff 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, var(--canvas) 0%, var(--canvas-tint) 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

/* ヘッダー */
.page-header { padding: 40px 0 26px; }

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

.brand-mark {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--accent) 0%, #6b76e8 100%);
  color: #fff;
  box-shadow: 0 6px 16px -6px var(--accent-ring);
}

.brand-mark svg { width: 23px; height: 23px; }

.page-header h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.tagline {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

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

.stat {
  display: flex;
  align-items: center;
  gap: 13px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 17px 19px;
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #f1f3f9;
  color: var(--muted);
}

.stat-icon svg { width: 20px; height: 20px; }

.stat-accent {
  background: linear-gradient(150deg, #ffffff 0%, var(--accent-soft) 100%);
  border-color: rgba(79, 91, 213, 0.18);
}

.stat-accent .stat-icon { background: #fff; color: var(--accent); }

.stat-body { display: flex; flex-direction: column; min-width: 0; }

.stat-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
  line-height: 1.5;
}

.stat-value {
  font-size: 27px;
  font-weight: 700;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.stat-accent .stat-value { color: var(--accent); }

/* ダッシュボードの最新振り返り */
.latest-review {
  grid-column: 1 / -1;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 16px 19px 17px;
  box-shadow: var(--shadow-md);
}

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

.latest-icon {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.latest-icon svg { width: 15px; height: 15px; }

.latest-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.latest-week {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.latest-comment {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14.5px;
  line-height: 1.75;
}

.latest-comment.is-empty { color: var(--muted); font-size: 13.5px; }

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

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

.panel-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 28px 0 12px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.panel-title::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--accent);
}

.panel-title:first-of-type { margin-top: 0; }

.count {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0 9px;
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

.form-row { flex-direction: row; }

.form-row input { flex: 1; min-width: 0; }

input[type="text"], textarea {
  font: inherit;
  color: inherit;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--item-border);
  border-radius: var(--radius-md);
  background: var(--item-bg);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  resize: vertical;
}

input[type="text"]::placeholder, textarea::placeholder { color: #a4abbe; }

input[type="text"]:focus, textarea:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

button { font: inherit; cursor: pointer; border: none; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-md);
  padding: 11px 18px;
  background-color: var(--accent);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0) 100%);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow: 0 6px 16px -10px rgba(79, 91, 213, 0.9);
  transition: background-color 0.15s, transform 0.08s, box-shadow 0.15s;
}

.btn-primary:hover { background-color: var(--accent-hover); box-shadow: 0 8px 20px -10px rgba(79, 91, 213, 0.95); }

.btn-primary:active { transform: translateY(1px); }

.btn-primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-icon-svg { width: 15px; height: 15px; }

/* 週次振り返り */
.panel-wide { margin-top: 20px; }

.week-picker {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px 12px;
}

.week-field { display: flex; flex-direction: column; gap: 4px; }

.week-field-label {
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

input[type="date"] {
  font: inherit;
  color: inherit;
  padding: 9px 12px;
  border: 1px solid var(--item-border);
  border-radius: var(--radius-md);
  background: var(--item-bg);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

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

.week-quick { display: flex; gap: 6px; padding-bottom: 1px; }

.btn-chip {
  border-radius: 999px;
  padding: 6px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s;
}

.btn-chip:hover { background: var(--accent); color: #fff; }

.btn-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-chip-quiet {
  flex: none;
  align-self: center;
  padding: 5px 12px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--item-border);
}

.week-range {
  padding-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.review-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.hint {
  flex: 1;
  min-width: 200px;
  font-size: 12px;
  color: var(--warn-text);
}

.badge-week {
  background: var(--accent-soft);
  color: var(--accent);
  margin-left: 8px;
  vertical-align: 1px;
}

.review-item .item-title { font-variant-numeric: tabular-nums; }

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

.item {
  position: relative;
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px 13px 12px 15px;
  background: var(--item-bg);
  border: 1px solid var(--item-border);
  border-radius: var(--radius-md);
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
}

/* 左端のアクセント（角丸に沿わせるため疑似要素で描く） */
.item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.item:hover {
  background: var(--item-hover);
  border-color: rgba(79, 91, 213, 0.28);
  box-shadow: var(--shadow-sm);
}

.item-body { flex: 1; min-width: 0; }

.item-title {
  font-weight: 600;
  line-height: 1.55;
  word-break: break-word;
}

.item-text {
  margin: 3px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #3d4560;
  font-size: 14px;
}

.item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.badge-done { background: var(--ok-bg); color: var(--ok-text); }

.badge-open { background: var(--warn-bg); color: var(--warn-text); }

/* 完了したタスク */
.item.done { background: var(--done-bg); }

.item.done::before { background: #c2c9d8; }

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

/* チェックボックス */
.item input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 19px;
  height: 19px;
  flex: none;
  margin: 3px 0 0;
  border: 1.5px solid #b8c0d4;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
}

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

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

.item input[type="checkbox"]:checked::after {
  content: "";
  width: 10px;
  height: 5.5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}

.item input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 削除ボタン */
.btn-icon {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: #a8b0c4;
  font-size: 17px;
  line-height: 1;
  opacity: 0.75;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}

.item:hover .btn-icon { opacity: 1; }

.btn-icon:hover { background: #fdecea; color: var(--danger); }

.btn-icon:focus-visible { outline: 2px solid var(--danger); outline-offset: 1px; }

/* 空の状態 */
.empty {
  margin: 2px 0 0;
  padding: 22px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--item-border);
  border-radius: var(--radius-md);
  background: rgba(250, 251, 254, 0.6);
}

/* トースト */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: rgba(27, 33, 54, 0.95);
  color: #fff;
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  letter-spacing: 0.03em;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.22s ease-out;
}

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

/* タブレット・小さめのウィンドウ（4枚並べると窮屈なので2列にする） */
@media (max-width: 1000px) {
  .dashboard { grid-template-columns: repeat(2, 1fr); }
}

/* スマートフォン */
@media (max-width: 780px) {
  .columns { grid-template-columns: 1fr; }
  .dashboard { grid-template-columns: 1fr; gap: 10px; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 24px; }
  .app { padding: 0 14px 48px; }
  .page-header { padding: 28px 0 20px; }
}

/* ダークモード */
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #12151f;
    --canvas-tint: #171b27;
    --panel: #1c2130;
    --panel-border: rgba(255, 255, 255, 0.08);

    --text: #e8eaf2;
    --muted: #949db5;

    --accent: #7b86ee;
    --accent-hover: #8b95f2;
    --accent-soft: rgba(123, 134, 238, 0.16);
    --accent-ring: rgba(123, 134, 238, 0.3);

    --item-bg: #1f2433;
    --item-border: rgba(255, 255, 255, 0.07);
    --item-hover: #242a3c;

    --done-bg: #1a1e2b;
    --done-text: #7d859b;

    --ok-bg: rgba(46, 160, 96, 0.18);
    --ok-text: #74d3a0;
    --warn-bg: rgba(214, 137, 46, 0.18);
    --warn-text: #e3ab6b;
    --danger: #ef7a72;
  }

  body {
    background:
      radial-gradient(1100px 520px at 15% -10%, #1e2333 0%, rgba(30, 35, 51, 0) 60%),
      linear-gradient(180deg, var(--canvas) 0%, var(--canvas-tint) 100%);
  }

  .stat-icon { background: #262c3d; color: #99a2ba; }

  .stat-accent { background: linear-gradient(150deg, #232941 0%, #1e2334 100%); }

  .stat-accent .stat-icon { background: #2c3350; }

  .item-text { color: #c3c9db; }

  .item input[type="checkbox"] { background: #171b27; border-color: #4a5372; }

  input[type="date"] { color-scheme: dark; }

  .btn-chip:hover { color: #12151f; }

  .btn-icon:hover { background: rgba(239, 122, 114, 0.16); }

  .empty { background: rgba(31, 36, 51, 0.5); }

  input[type="text"]:focus, textarea:focus, input[type="date"]:focus { background: #262c3d; }

  .toast { background: rgba(240, 242, 250, 0.95); color: #1b2136; }
}
