:root {
  --bg: #eef1f7;
  --bg-glow-1: rgba(99, 102, 241, .14);
  --bg-glow-2: rgba(45, 212, 191, .12);
  --panel: #ffffff;
  --panel-soft: #f7f8fc;
  --border: #e4e7f0;
  --border-strong: #d3d8e6;
  --text: #1b2233;
  --muted: #737d92;
  --accent: #4f5ee8;
  --accent-soft: rgba(79, 94, 232, .1);
  --danger: #d84a4a;
  --danger-soft: rgba(216, 74, 74, .1);
  --done: #12a06a;
  --done-soft: rgba(18, 160, 106, .1);
  --shadow-sm: 0 1px 2px rgba(23, 30, 51, .05);
  --shadow-md: 0 6px 20px -8px rgba(23, 30, 51, .18), 0 1px 3px rgba(23, 30, 51, .05);
  --shadow-lg: 0 18px 40px -20px rgba(23, 30, 51, .35);
  --radius: 16px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1119;
    --bg-glow-1: rgba(99, 102, 241, .22);
    --bg-glow-2: rgba(45, 212, 191, .14);
    --panel: #171b26;
    --panel-soft: #1d2230;
    --border: #272d3d;
    --border-strong: #384054;
    --text: #e7eaf3;
    --muted: #8f99ae;
    --accent: #8b95ff;
    --accent-soft: rgba(139, 149, 255, .14);
    --danger: #f28080;
    --danger-soft: rgba(242, 128, 128, .14);
    --done: #3fd39a;
    --done-soft: rgba(63, 211, 154, .14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, .6);
    --shadow-lg: 0 20px 45px -22px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 40px 24px 72px;
  min-height: 100vh;
  background:
    radial-gradient(60rem 30rem at 12% -8%, var(--bg-glow-1), transparent 60%),
    radial-gradient(50rem 28rem at 92% 4%, var(--bg-glow-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Meiryo", sans-serif;
  font-feature-settings: "palt" 1;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1020px; margin: 0 auto; }

/* ヘッダー */
.page-header { margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #22d3ee));
  color: #fff;
  box-shadow: var(--shadow-md);
}
.brand-mark svg { width: 24px; height: 24px; }
.page-header h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }

/* ダッシュボード */
.dashboard {
  margin-bottom: 26px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stat {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 15px;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--border-strong);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-label {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .06em;
}
.stat-figure { display: flex; align-items: baseline; gap: 5px; }
.stat-value {
  font-size: 2.1rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.stat-unit { color: var(--muted); font-size: .8rem; }
.stat-accent::before { background: linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 55%, #22d3ee)); }
.stat-accent .stat-value { color: var(--accent); }

/* 完了タスクは一覧のバッジと同じ緑で揃える */
.stat-positive::before { background: linear-gradient(var(--done), color-mix(in srgb, var(--done) 55%, #22d3ee)); }
.stat-positive .stat-value { color: var(--done); }

/* 最新の振り返り（ダッシュボード内） */
.latest-review {
  grid-column: 1 / -1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 18px 16px;
  box-shadow: var(--shadow-sm);
}
.latest-review .stat-label { margin-bottom: 7px; }
.latest-review-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.latest-review-week {
  font-weight: 700;
  font-size: .92rem;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.latest-review-comment {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .89rem;
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
}
.latest-review-empty { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }

/* レイアウト */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-md);
}
.panel-wide { grid-column: 1 / -1; }
.panel h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 16px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .01em;
}
.panel-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}
.panel-icon svg { width: 17px; height: 17px; }

/* フォーム */
.form { display: flex; flex-direction: column; gap: 9px; margin-bottom: 18px; }
.form-inline { flex-direction: row; }
.form-inline input { flex: 1; min-width: 0; }
.form-actions { display: flex; justify-content: flex-end; }

/* 週の選択 */
.week-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-label { color: var(--muted); font-size: .78rem; font-weight: 600; letter-spacing: .04em; }
.week-picker input[type="date"] { width: auto; padding: 7px 11px; }
.week-range {
  color: var(--muted);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}
.week-range.is-existing { color: var(--accent); font-weight: 600; }

input[type="text"], input[type="date"], textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--panel-soft);
  color: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea { resize: vertical; min-height: 76px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, textarea:focus {
  outline: none;
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease, box-shadow .15s ease;
}
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  padding: 10px 20px;
  border: none;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 78%, #22d3ee));
  color: #fff;
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 10px 22px -10px color-mix(in srgb, var(--accent) 90%, transparent); }

.btn-small {
  padding: 4px 11px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
}
.btn-small:hover { border-color: var(--border-strong); color: var(--text); background: var(--panel-soft); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.btn-toggle:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-toggle.is-done { color: var(--done); border-color: color-mix(in srgb, var(--done) 45%, transparent); }
.btn-toggle.is-done:hover { border-color: var(--done); color: var(--done); background: var(--done-soft); }

/* 一覧 */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--panel-soft);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  animation: item-in .22s ease both;
}
.item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.item-head { display: flex; align-items: center; gap: 10px; }
.item-title { font-weight: 600; font-size: .95rem; flex: 1; word-break: break-word; }
.item-body {
  margin: 8px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--border-strong);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .89rem;
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
}
.item-meta {
  margin-top: 9px;
  color: var(--muted);
  font-size: .74rem;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.item-actions { display: flex; gap: 6px; }

.item.done { background: transparent; border-style: dashed; }
.item.done .item-title { text-decoration: line-through; color: var(--muted); font-weight: 500; }

.badge {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  border: 1px solid transparent;
}
.badge-open { color: var(--accent); background: var(--accent-soft); }
.badge-done { color: var(--done); background: var(--done-soft); }
.badge-week { color: var(--accent); background: var(--accent-soft); }

.empty {
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
  padding: 22px 8px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}

/* メッセージ（トースト） */
.message {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  margin: 0;
  max-width: min(90vw, 420px);
  padding: 0;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--danger);
  color: var(--danger);
  font-size: .85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.message:not(:empty) {
  padding: 10px 20px;
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes item-in {
  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: 760px) {
  body { padding: 26px 16px 60px; }
  .columns { grid-template-columns: 1fr; }
  .dashboard { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 1.85rem; }
  .panel { padding: 18px; }
}

@media (max-width: 420px) {
  .dashboard { grid-template-columns: 1fr; }
  .item-head { flex-wrap: wrap; }
}
