:root {
  --accent: #2563eb;
  --accent-soft: #e3ecfd;
  --text: #1c2330;
  --muted: #66707e;
  --border: #d8dde5;
  --surface: #ffffff;
  --bg: #f5f6f8;
  --danger: #c62828;
  --overdue: #c62828;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 0.5rem; }
button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); border-color: var(--danger); }
input, select, textarea {
  font: inherit;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: var(--surface);
  color: var(--text);
  margin-top: 0.3rem;
}
input[type="checkbox"] { width: auto; margin-top: 0; }
label { display: block; font-size: 0.9rem; margin-bottom: 0.9rem; }
.error { color: var(--danger); min-height: 1.2em; font-size: 0.88rem; }
.note { color: var(--muted); font-size: 0.9rem; }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }
.req { color: var(--danger); font-size: 0.75rem; }

/* 認証画面 */
.auth-view { display: flex; justify-content: center; padding: 3rem 1rem; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.6rem;
  width: 100%;
  max-width: 380px;
}
.auth-card h1 { margin-bottom: 0.6rem; }
.auth-card p { color: var(--muted); font-size: 0.92rem; }
.auth-card button { width: 100%; }

/* ヘッダーとタブ */
.app-header {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.8rem 1rem 0;
  z-index: 5;
}
.app-header h1 { margin-bottom: 0.6rem; }
.tabs { display: flex; gap: 0.4rem; }
.tab {
  border: none;
  background: transparent;
  padding: 0.5rem 0.8rem;
  border-radius: 10px 10px 0 0;
  color: var(--muted);
}
.tab.active { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); font-weight: 600; }

.tab-panel { padding: 1rem; max-width: 860px; margin: 0 auto; padding-bottom: 6.5rem; }

/* 絞り込み */
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.controls label { margin-bottom: 0; font-size: 0.82rem; color: var(--muted); }
.filter-note { color: var(--muted); font-size: 0.82rem; margin: 0.2rem 0 0.6rem; }

/* タスク行 */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.55rem;
  cursor: pointer;
}
.task-row .toggle { width: 1.3rem; height: 1.3rem; margin-top: 0.15rem; flex: none; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; word-break: break-word; }
.task-row.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-meta { display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; font-size: 0.8rem; color: var(--muted); margin-top: 0.25rem; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
  font-size: 0.75rem;
}
.dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.prio-high { color: var(--danger); font-weight: 700; }
.status-overdue { color: var(--overdue); font-weight: 700; }
.restore-btn { flex: none; padding: 0.35rem 0.7rem; font-size: 0.82rem; }

/* 追加ボタン (FAB): 内側の余白は上下対称にし、安全領域は配置側で調整 */
.fab {
  position: fixed;
  right: 1.1rem;
  bottom: max(1.1rem, env(safe-area-inset-bottom));
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1.4rem;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(20, 40, 90, 0.28);
  z-index: 10;
  line-height: 1.2;
}

/* フォームシート */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  padding: 1.2rem 1.2rem max(1.2rem, env(safe-area-inset-bottom));
}
@media (min-width: 640px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 18px; }
}
.sheet h2 { margin: 0 0 1rem; font-size: 1.1rem; }
.field-label { font-size: 0.9rem; display: block; margin-bottom: 0.2rem; }
.static-value { margin: 0 0 0.9rem; font-size: 1rem; display: flex; align-items: center; gap: 0.45rem; }
.weekday-row { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.4rem 0 0.9rem; }
.weekday-row label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  margin: 0;
  font-size: 0.85rem;
}
.checkbox-row { display: flex; align-items: center; gap: 0.5rem; }
.sheet-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.sheet-actions .spacer { flex: 1; }
