/* ---------- カラー（ライト） ---------- */
:root {
  --bg: #f2f2f7;
  --panel: #ffffff;
  --panel-hover: rgba(0, 0, 0, .025);
  --field: #ffffff;
  --separator: rgba(0, 0, 0, .09);
  --border: rgba(0, 0, 0, .13);
  --text: #1d1d1f;
  --secondary: #6e6e73;
  --tertiary: #8e8e93;
  --fill: rgba(120, 120, 128, .12);
  --fill-strong: rgba(120, 120, 128, .2);
  --blue: #007aff;
  --blue-press: #0062cc;
  --green: #30a14e;
  --red: #e0342b;
  --toolbar: rgba(246, 246, 248, .72);
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 20px rgba(0, 0, 0, .05);
}
/* ---------- カラー（ダーク） ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --panel: #2c2c2e;
    --panel-hover: rgba(255, 255, 255, .04);
    --field: #1c1c1e;
    --separator: rgba(255, 255, 255, .1);
    --border: rgba(255, 255, 255, .16);
    --text: #f5f5f7;
    --secondary: #a1a1a6;
    --tertiary: #8e8e93;
    --fill: rgba(120, 120, 128, .24);
    --fill-strong: rgba(120, 120, 128, .36);
    --blue: #0a84ff;
    --blue-press: #0a6ed1;
    --green: #32d74b;
    --red: #ff453a;
    --toolbar: rgba(38, 38, 40, .72);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans",
               "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: .005em;
}

/* ---------- ツールバー ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--toolbar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
  text-align: center;
  padding: 13px 16px;
}
.toolbar h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
}

.wrap { max-width: 680px; margin: 0 auto; padding: 24px 20px 72px; }

/* ---------- セクション ---------- */
section { margin-bottom: 26px; }
.label {
  font-size: 12px;
  font-weight: 590;
  color: var(--secondary);
  margin: 0 0 7px 3px;
  letter-spacing: .01em;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--separator);
  border-radius: 11px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel.pad { padding: 14px; }

/* ---------- ダッシュボード ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); }
.stat { padding: 16px 10px; text-align: center; border-left: 1px solid var(--separator); }
.stat:first-child { border-left: none; }
.stat .num {
  font-size: 30px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.stat .cap { font-size: 11px; color: var(--secondary); margin-top: 2px; }
.stat.accent .num { color: var(--blue); }

/* ダッシュボード内の「最新の振り返り」 */
.latest {
  border-top: 1px solid var(--separator);
  padding: 11px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.latest .cap { font-size: 11px; color: var(--secondary); flex: none; padding-top: 1px; }
.latest .week { font-weight: 590; font-variant-numeric: tabular-nums; }
.latest .text {
  color: var(--secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.latest .none { color: var(--tertiary); }

/* 週の切り替えバー */
.weekbar { display: flex; align-items: center; gap: 8px; }
.weekbar .week { font-weight: 590; font-variant-numeric: tabular-nums; }
.weekbar .spacer { flex: 1; }
button.step {
  background: var(--fill);
  color: var(--text);
  box-shadow: none;
  padding: 2px 10px 4px;
  font-size: 15px;
  line-height: 1.2;
  border-radius: 6px;
}
button.step:hover { background: var(--fill-strong); }
button.step:disabled { opacity: .35; background: var(--fill); }

/* ---------- 入力 ---------- */
input[type="text"], textarea {
  display: block;
  width: 100%;
  padding: 7px 10px;
  font: inherit;
  color: inherit;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 7px;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input[type="text"]::placeholder, textarea::placeholder { color: var(--tertiary); }
input[type="text"]:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--blue) 28%, transparent);
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.stack > * + * { margin-top: 9px; }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.hint { font-size: 11px; color: var(--tertiary); }
.inline { display: flex; gap: 9px; align-items: center; }
.inline input[type="text"] { flex: 1; min-width: 0; }

/* ---------- ボタン ---------- */
button {
  font: inherit;
  font-weight: 500;
  border: none;
  border-radius: 7px;
  padding: 6px 15px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 1.5px rgba(0, 0, 0, .12);
  transition: background-color .12s ease, opacity .12s ease;
}
button:hover { background: color-mix(in srgb, var(--blue) 92%, #000); }
button:active { background: var(--blue-press); }
button:focus-visible { outline: none; box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--blue) 28%, transparent); }
button:disabled { opacity: .42; cursor: default; box-shadow: none; background: var(--blue); }
button.ghost {
  background: transparent;
  color: var(--tertiary);
  box-shadow: none;
  padding: 3px 9px;
  font-size: 12px;
  border-radius: 6px;
  opacity: .85;
}
button.ghost:hover { background: var(--fill); color: var(--red); opacity: 1; }

/* ---------- 一覧 ---------- */
ul { list-style: none; margin: 0; padding: 0; }
li {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 11px 14px;
  position: relative;
  transition: background-color .12s ease;
}
li + li::before {
  content: "";
  position: absolute;
  top: 0; left: 14px; right: 0;
  border-top: 1px solid var(--separator);
}
li:hover { background: var(--panel-hover); }
li.empty { color: var(--tertiary); justify-content: center; padding: 22px 14px; }
.grow { flex: 1; min-width: 0; }
.title { font-weight: 590; word-break: break-word; }
.body { white-space: pre-wrap; word-break: break-word; margin-top: 1px; color: var(--text); }
.meta { font-size: 11px; color: var(--tertiary); margin-top: 3px; font-variant-numeric: tabular-nums; }
.done .title { text-decoration: line-through; color: var(--tertiary); text-decoration-color: var(--tertiary); }

/* ---------- バッジ ---------- */
.badge {
  font-size: 11px;
  line-height: 1.45;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--fill);
  color: var(--secondary);
  white-space: nowrap;
  margin-top: 1px;
}
.badge.ok { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }

/* ---------- チェックボックス（macOS風） ---------- */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--field);
  cursor: pointer;
  position: relative;
  transition: background-color .12s ease, border-color .12s ease;
}
input[type="checkbox"]:hover { border-color: var(--blue); }
input[type="checkbox"]:checked { background: var(--blue); border-color: var(--blue); }
input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 5px; top: 1.5px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 1.8px 1.8px 0;
  border-radius: 1px;
  transform: rotate(43deg);
}
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--blue) 28%, transparent);
}

@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .stat { border-left: none; border-top: 1px solid var(--separator); padding: 13px 10px; }
  .stat:first-child { border-top: none; }
}

/* ---------- タスクの日程 ---------- */
.dates { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.dates label { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--tertiary); }
input[type="date"] {
  font: inherit;
  font-size: 12px;
  color: inherit;
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
  outline: none;
  font-variant-numeric: tabular-nums;
}
input[type="date"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 26%, transparent);
}

/* 分解して追加した工程（子タスク） */
li.child { padding-left: 32px; }
li.child .title { font-weight: 400; }
li.child::after {
  content: "";
  position: absolute;
  left: 20px;
  top: 14px;
  width: 6px;
  border-top: 1px solid var(--border);
}

/* ---------- 分解の提案 ---------- */
li.proposal { background: var(--fill); display: block; padding: 12px 14px 12px 32px; }
.phead { display: flex; align-items: center; gap: 8px; font-weight: 590; margin-bottom: 6px; }
.pitem { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.pitem input[type="text"] { flex: 1; min-width: 0; padding: 4px 8px; font-size: 12px; }
.pdates { font-size: 11px; color: var(--tertiary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pfoot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 10px; }

/* ---------- 工程表 ---------- */
.ganttbar { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--separator); }
.ganttbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--fill); border-radius: 7px; padding: 2px; gap: 2px; }
.seg button {
  background: transparent;
  color: var(--text);
  box-shadow: none;
  padding: 3px 13px;
  font-size: 12px;
  border-radius: 5px;
}
.seg button:hover:not(.on) { background: var(--fill-strong); }
.seg button.on { background: var(--panel); box-shadow: 0 1px 2px rgba(0, 0, 0, .14); }

.gantt { padding: 12px 14px 14px; overflow-x: auto; }
.gchart { position: relative; min-width: 460px; }
.ghead { position: relative; height: 16px; margin-bottom: 4px; }
.gtlabel { position: absolute; top: 0; font-size: 10px; color: var(--tertiary); padding-left: 4px; white-space: nowrap; }
.gline { display: grid; grid-template-columns: 148px 1fr; gap: 10px; align-items: center; padding: 3px 0; }
.gname {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gname.child { padding-left: 10px; color: var(--secondary); }
.gname.done { color: var(--tertiary); text-decoration: line-through; }
.gtrack { position: relative; height: 18px; background: var(--fill); border-radius: 5px; }
.gbar {
  position: absolute;
  top: 3px;
  bottom: 3px;
  background: var(--blue);
  border-radius: 4px;
  min-width: 3px;
}
.gbar.child { top: 5px; bottom: 5px; opacity: .78; }
.gbar.done { background: var(--green); opacity: .6; }
.gtick { position: absolute; top: 16px; bottom: 0; width: 1px; background: var(--separator); pointer-events: none; }
.gtoday { position: absolute; top: 12px; bottom: 0; width: 1px; background: var(--red); opacity: .75; pointer-events: none; }
.gnone { color: var(--tertiary); padding: 14px 0; text-align: center; }
.gnote { font-size: 11px; color: var(--tertiary); margin-top: 10px; }
/* 親タスクに日程が無い場合の、子の工程をまとめたバー */
.gbar.summary {
  background: color-mix(in srgb, var(--blue) 18%, transparent);
  border: 1px solid var(--blue);
  opacity: .8;
}
