/* ===== 配色とトークン ===== */
:root {
  color-scheme: light dark;

  --bg: #f4f5f8;
  --card: #ffffff;
  --surface: #f7f8fb;        /* 入力欄まわり・一覧カードの下地 */
  --surface-hover: #f1f3f9;

  --text: #14181f;
  --muted: #626b7a;
  --faint: #98a0ae;
  --line: #e5e8ef;
  --line-strong: #d5dae4;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-weak: #eef0fe;
  --accent-line: #d7d9fb;

  --warn: #a15c07;
  --warn-bg: #fff6e5;
  --warn-line: #f6dca8;

  --done: #15803d;
  --done-bg: #eaf6ee;
  --done-line: #c2e2cd;

  --danger: #b91c1c;

  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 12px 28px -18px rgba(16, 24, 40, .45);
  --shadow-lift: 0 1px 2px rgba(16, 24, 40, .06), 0 10px 20px -12px rgba(16, 24, 40, .35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --card: #161a21;
    --surface: #1c212a;
    --surface-hover: #222833;

    --text: #e8eaf0;
    --muted: #9aa3b2;
    --faint: #79818f;
    --line: #262c37;
    --line-strong: #333b48;

    --accent: #7c7cf5;
    --accent-hover: #8d8dfa;
    --accent-weak: #1e2036;
    --accent-line: #33356a;

    --warn: #f0b95f;
    --warn-bg: #2c2415;
    --warn-line: #4a3c1d;

    --done: #58c98a;
    --done-bg: #16281e;
    --done-line: #26482f;

    --danger: #f08a84;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 14px 30px -20px rgba(0, 0, 0, .9);
    --shadow-lift: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 24px -14px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }

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

.icon { width: 1em; height: 1em; flex: none; }

/* ===== ヘッダー ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #06b6d4));
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.35;
}
.subtitle { margin: 0; color: var(--faint); font-size: 12px; line-height: 1.4; }
.today {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

main { max-width: 1040px; margin: 0 auto; padding: 26px 20px; }

/* ===== ダッシュボード ===== */
.dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-accent {
  background: var(--accent-weak);
  border-color: var(--accent-line);
}
.stat-label {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-memo { background: var(--accent); }
.dot-task { background: #0ea5e9; }
.dot-open { background: #f59e0b; }
.dot-done { background: var(--done); }

.stat-value {
  margin: 4px 0 0;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.stat-value .unit { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

/* 進捗バー */
.progress-row {
  margin-top: 14px;
  padding: 12px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
}
.progress-caption { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.progress {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-hover);
  overflow: hidden;
}
.progress span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--done) 70%, var(--accent)));
  transition: width .35s ease;
}
.progress-text {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ===== パネル ===== */
.columns {
  margin-top: 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
}
.panel-title .icon { width: 17px; height: 17px; color: var(--accent); }

.list-title {
  margin: 24px 0 11px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--faint);
}

/* ===== 入力欄 ===== */
.composer {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.composer-inline { flex-direction: row; align-items: center; }
.composer-inline input { flex: 1; }

input, textarea {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
textarea { resize: vertical; min-height: 76px; }

/* ===== ボタン ===== */
button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
button:active { transform: translateY(1px); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary .icon { width: 15px; height: 15px; }

.btn-small {
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  background: var(--card);
  border-color: var(--line-strong);
  color: var(--muted);
}
.btn-toggle { color: var(--done); border-color: var(--done-line); }
.btn-toggle:hover { background: var(--done-bg); }
.btn-undo:hover { background: var(--surface-hover); color: var(--text); }
.btn-delete { color: var(--muted); }
.btn-delete:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

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

.item {
  position: relative;
  padding: 13px 15px 12px 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: background .15s, box-shadow .15s, border-color .15s;
}
/* 左端の細い色帯 */
.item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.item:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lift);
}
.item-open::before { background: #f59e0b; }
.item-done::before { background: var(--done); }
.item-done {
  /* 完了したタスクもうっすら緑を帯びた下地で、背景に埋もれないようにする */
  background: color-mix(in srgb, var(--done-bg) 55%, var(--surface));
  border-color: color-mix(in srgb, var(--done-line) 55%, var(--line));
}
.item-done:hover { background: color-mix(in srgb, var(--done-bg) 80%, var(--surface)); }

.item-head { display: flex; align-items: center; gap: 8px; }
.item-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  letter-spacing: .01em;
  word-break: break-word;
}
.item-done .item-title { text-decoration: line-through; text-decoration-color: var(--faint); color: var(--muted); }

.item-actions { display: flex; gap: 6px; flex: none; opacity: .55; transition: opacity .15s; }
.item:hover .item-actions, .item:focus-within .item-actions { opacity: 1; }

.item-body {
  margin: 9px 0 0;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

.item-meta {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.badge {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid;
}
.badge-open { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.badge-done { color: var(--done); background: var(--done-bg); border-color: var(--done-line); }

.empty {
  padding: 26px 14px;
  text-align: center;
  font-size: 13.5px;
  color: var(--faint);
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

/* ===== トースト ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: color-mix(in srgb, var(--text) 92%, transparent);
  color: var(--card);
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 8px 26px -8px rgba(16, 24, 40, .5);
  animation: toast-in .22s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ===== レスポンシブ ===== */
@media (max-width: 900px) {
  .dashboard { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .columns { grid-template-columns: 1fr; }
  .today { display: none; }
}
@media (max-width: 560px) {
  .dashboard { grid-template-columns: 1fr; }
  .progress-row { flex-wrap: wrap; }
  .progress { order: 3; flex-basis: 100%; }
}

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