:root {
  --bg: #f7f8fa;
  --bg-tint: radial-gradient(1200px 400px at 50% -200px, #e7ecff 0%, transparent 70%);
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e6e9ef;
  --border-strong: #d6dbe4;
  --text: #14181f;
  --muted: #6b7383;
  --faint: #9aa2b1;
  --accent: #4f5bd5;
  --accent-soft: #eef0fe;
  --danger: #d94a4a;
  --danger-soft: #fdeceb;
  --ok: #1f9d68;
  --ok-soft: #e7f6ee;
  --warn: #b5761a;
  --warn-soft: #fdf3e0;
  --shadow-sm: 0 1px 2px rgba(19, 24, 33, .04);
  --shadow-md: 0 6px 20px -8px rgba(19, 24, 33, .16), 0 1px 2px rgba(19, 24, 33, .04);
  --radius: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --bg-tint: radial-gradient(1200px 400px at 50% -200px, #1b2138 0%, transparent 70%);
    --surface: #161a22;
    --surface-soft: #1b202a;
    --border: #262c38;
    --border-strong: #333b4a;
    --text: #e8ebf1;
    --muted: #98a1b2;
    --faint: #6f7889;
    --accent: #8b95f5;
    --accent-soft: #232945;
    --danger: #f08585;
    --danger-soft: #3a2429;
    --ok: #5cc99a;
    --ok-soft: #17322a;
    --warn: #dfae62;
    --warn-soft: #33291a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-md: 0 8px 24px -10px rgba(0, 0, 0, .6), 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-tint), var(--bg);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  letter-spacing: .01em;
}

/* ---------- ヘッダー ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: .04em;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #b6a4ff));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.today {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

/* ---------- ダッシュボード ---------- */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 28px;
}
.stat {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, transform .2s ease;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-head { display: flex; align-items: center; gap: 8px; }
.stat-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--faint);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.stat-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .06em;
}
.stat-value {
  display: block;
  margin-top: 6px;
  font-size: 34px;
  font-weight: 660;
  line-height: 1.15;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat-accent { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.stat-accent .stat-icon { stroke: var(--accent); }
.stat-accent .stat-value { color: var(--accent); }
.stat-bar {
  margin-top: 10px;
  height: 4px;
  border-radius: 99px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  overflow: hidden;
}
.stat-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #9fd6c0));
  transition: width .35s ease;
}

/* ---------- エラー ---------- */
.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0 0 18px;
  font-size: 14px;
}

/* ---------- パネル ---------- */
.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .06em;
}
.chip {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0 9px;
  line-height: 1.7;
}

/* ---------- フォーム ---------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.form-row { display: flex; flex-direction: row; gap: 10px; align-items: center; }
.due-field {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.due-label { font-size: 12px; color: var(--muted); white-space: nowrap; letter-spacing: .06em; }

input, textarea {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  color: inherit;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; min-height: 76px; }
input:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input[type="date"] { font-variant-numeric: tabular-nums; }

/* ---------- ボタン ---------- */
button {
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
button:active { transform: translateY(1px); }
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }

.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-ghost {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--muted);
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }
.btn-quiet {
  background: transparent;
  color: var(--faint);
}
.btn-quiet:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- 一覧 ---------- */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.item {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.item-body { flex: 1; min-width: 0; }
.item-title {
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
}
.item-text {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.item.done { background: var(--surface-soft); }
.item.done .item-title { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }

.item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  opacity: .75;
  transition: opacity .15s ease;
}
.item:hover .item-actions, .item:focus-within .item-actions { opacity: 1; }

/* ---------- バッジ ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: .02em;
  border-radius: 99px;
  padding: 2px 9px;
  border: 1px solid transparent;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 99px;
  background: currentColor;
}
.badge-done { background: var(--ok-soft); color: var(--ok); }
.badge-open { background: var(--warn-soft); color: var(--warn); }
.badge-due { background: var(--surface-soft); color: var(--muted); border-color: var(--border); }
.badge-today { background: var(--accent-soft); color: var(--accent); }
.badge-overdue { background: var(--danger-soft); color: var(--danger); }

.empty {
  margin: 2px 0 0;
  padding: 22px 0;
  text-align: center;
  color: var(--faint);
  font-size: 13.5px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* ---------- 狭い画面 ---------- */
@media (max-width: 980px) {
  .dashboard { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .columns { grid-template-columns: 1fr; }
  .dashboard { gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 28px; }
  .stat-label { font-size: 11px; }
}

@media (max-width: 480px) {
  main { padding: 20px 14px 60px; }
  .form-row { flex-wrap: wrap; }
  .form-row .btn-primary { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
