/* daily-todo — 毎日やること。スマホファースト・1ファイル完結。 */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1f2937;
  --ink-sub: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --done: #10b981;
  --ring-bg: #e5e7eb;
  --danger: #ef4444;
  --radius: 14px;
  --hm0: #ebedf0; --hm1: #c6e7d0; --hm2: #7bd49a; --hm3: #34b96a; --hm4: #1a8f4c;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; line-height: 1.5;
}

/* ヘッダ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--ink); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; }
.nav a { color: #cbd5e1; text-decoration: none; }
.nav a.active { color: #fff; font-weight: 700; }
.nav .user { color: #93c5fd; font-weight: 600; }
.nav .logout { color: #94a3b8; }

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 64px; }
.flash {
  background: #fef3c7; border: 1px solid #fde68a; color: #92400e;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 14px;
}

/* ヒーロー（日付＋スタッツ） */
.hero { margin: 4px 0 18px; }
.hero-date { font-size: 15px; color: var(--ink-sub); margin-bottom: 12px; }
.hero-date span { font-size: 13px; }
.hero-stats { display: flex; gap: 14px; }
.stat {
  flex: 1; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.stat-num { font-size: 34px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--ink-sub); }

/* 円ゲージ（達成率） */
.ring {
  width: 84px; height: 84px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p, 0) * 1%), var(--ring-bg) 0);
  display: grid; place-items: center;
  transition: background .35s ease;
}
.ring-inner {
  width: 64px; height: 64px; border-radius: 50%; background: var(--card);
  display: grid; place-items: center; line-height: 1;
}
.ring-inner span { font-size: 24px; font-weight: 800; }
.ring-inner small { font-size: 12px; color: var(--ink-sub); }

/* セクション・タスク */
.sec { margin: 22px 0; }
.sec-title {
  font-size: 14px; font-weight: 700; color: var(--ink-sub);
  margin: 0 0 10px; letter-spacing: .02em;
}
.sec-title small { font-weight: 400; }
.tasklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.toggle {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 14px; background: none; border: 0; cursor: pointer;
  text-align: left; font: inherit; color: inherit;
}
.toggle:active { background: #f9fafb; }
.check {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 7px;
  border: 2px solid #cbd5e1; background: #fff; position: relative; transition: .15s;
}
.check::after {
  content: ""; position: absolute; left: 7px; top: 3px;
  width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0); transition: transform .15s;
}
.task.is-done .check { background: var(--done); border-color: var(--done); }
.task.is-done .check::after { transform: rotate(45deg) scale(1); }
.task-text { display: flex; flex-direction: column; gap: 2px; }
.task-title { font-size: 15px; font-weight: 600; }
.task-note { font-size: 12px; color: var(--ink-sub); }
.task.is-done .task-title { color: var(--ink-sub); text-decoration: line-through; }

.empty { color: var(--ink-sub); text-align: center; padding: 24px; }
.empty a { color: var(--accent); }

/* ヒートマップ（継続の記録） */
.heatmap-wrap { margin-top: 28px; }
.heatmap { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 6px; }
.hm-col { display: flex; flex-direction: column; gap: 3px; }
.hm-cell {
  width: 13px; height: 13px; border-radius: 3px; background: var(--hm0); flex: 0 0 auto;
}
.hm-cell.lv1 { background: var(--hm1); }
.hm-cell.lv2 { background: var(--hm2); }
.hm-cell.lv3 { background: var(--hm3); }
.hm-cell.lv4 { background: var(--hm4); }
.hm-cell.is-future { background: transparent; }
.hm-cell.is-today { outline: 2px solid var(--accent); outline-offset: 1px; }
.hm-legend {
  display: flex; align-items: center; gap: 4px; justify-content: flex-end;
  margin-top: 8px; font-size: 11px; color: var(--ink-sub);
}
.hm-legend .hm-cell { width: 11px; height: 11px; }

/* ログイン */
.login {
  max-width: 360px; margin: 8vh auto 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 28px 22px;
}
.login-title { font-size: 22px; font-weight: 800; margin: 0 0 4px; text-align: center; }
.login-sub { font-size: 13px; color: var(--ink-sub); text-align: center; margin: 0 0 20px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-sub); }
.field select, .field input {
  font-size: 16px; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); width: 100%;
}
.or { text-align: center; font-size: 12px; color: var(--ink-sub); }
.login-note { font-size: 12px; color: var(--ink-sub); text-align: center; margin: 16px 0 0; }

/* ボタン */
.btn-primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 12px 16px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-primary:active { background: var(--accent-ink); }
.btn-primary.block { width: 100%; }

/* 設定画面 */
.page-title { font-size: 20px; font-weight: 800; margin: 4px 0 2px; }
.page-sub { font-size: 13px; color: var(--ink-sub); margin: 0 0 18px; }
.set-sec { margin: 18px 0; }
.set-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.set-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.set-edit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.set-edit select, .set-edit input {
  font-size: 14px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.set-edit input[name="title"] { flex: 1 1 140px; }
.set-edit input[name="note"] { flex: 1 1 120px; }
.set-ctl { display: flex; gap: 6px; }
.set-ctl form { display: inline; margin: 0; }
.btn-mini {
  background: #eef2ff; color: var(--accent-ink); border: 1px solid #dbe3ff;
  border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.btn-icon {
  width: 34px; height: 34px; border: 1px solid var(--line); background: #fff;
  border-radius: 8px; font-size: 15px; cursor: pointer; color: var(--ink-sub);
}
.btn-icon.danger { color: var(--danger); border-color: #fecaca; }
.set-empty { color: var(--ink-sub); font-size: 13px; }

.set-add { margin-top: 24px; border-top: 1px dashed var(--line); padding-top: 18px; }
.add-form { display: flex; flex-wrap: wrap; gap: 8px; }
.add-form select, .add-form input {
  font-size: 15px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff;
}
.add-form input[name="title"] { flex: 1 1 160px; }
.add-form input[name="note"] { flex: 1 1 130px; }

/* PC では少しゆとり */
@media (min-width: 640px) {
  .stat-num { font-size: 38px; }
  .ring { width: 92px; height: 92px; }
  .ring-inner { width: 70px; height: 70px; }
}
