/* ---- テーマ（ライト / ダークは OS 設定に追従）---- */
:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #9aa5b1;
  --border: #e4e7eb;
  --accent: #4f46e5;
  --accent-weak: #eef2ff;
  --danger: #e02424;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --card: #21242b;
    --text: #e4e7eb;
    --muted: #7b8794;
    --border: #2f343d;
    --accent: #818cf8;
    --accent-weak: #2a2f45;
    --danger: #f98080;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

/* ---- ベース ---- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 2.5rem 1rem;
  display: flex;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", sans-serif;
  line-height: 1.5;
}

/* ---- カード ---- */
.app {
  width: 100%;
  max-width: 30rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.app__title {
  margin: 0 0 1.25rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---- 入力フォーム ---- */
.add-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.add-form__input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s;
}

.add-form__input:focus {
  outline: none;
  border-color: var(--accent);
}

.add-form__btn {
  padding: 0.6rem 1.1rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition:
    filter 0.15s,
    transform 0.05s;
}

.add-form__btn:hover {
  filter: brightness(1.08);
}

.add-form__btn:active {
  transform: translateY(1px);
}

/* ---- リスト ---- */
.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.task-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* 完了チェックボックス */
.task-list input[type="checkbox"] {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* タスク文言（span）と編集中の入力欄が同じ幅を取る */
.task-list li > span,
.task-list input[type="text"] {
  flex: 1;
  min-width: 0;
}

.task-list li > span {
  word-break: break-word;
}

/* 編集中の入力欄 */
.task-list input[type="text"] {
  padding: 0.3rem 0.45rem;
  font-size: 1rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 6px;
}

.task-list input[type="text"]:focus {
  outline: none;
}

/* 完了したタスク */
.task-list li.done > span {
  text-decoration: line-through;
  color: var(--muted);
}

/* ---- 行内の操作ボタン（Edit / Delete）---- */
.task-list input[type="button"] {
  flex: none;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s;
}

.task-list [data-action="edit"]:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-weak);
}

.task-list [data-action="delete"]:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* ---- スクリーンリーダー専用（見た目は隠す）---- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
