:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #000000;
  --muted: #8e8e93;
  --sep: rgba(60, 60, 67, 0.18);
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --fill: rgba(120, 120, 128, 0.12);
  --tabbar: rgba(249, 249, 249, 0.94);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #ffffff;
    --muted: #8e8e93;
    --sep: rgba(84, 84, 88, 0.6);
    --blue: #0a84ff;
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --fill: rgba(120, 120, 128, 0.24);
    --tabbar: rgba(29, 29, 31, 0.94);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Yu Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }

.screen {
  max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 96px);
}
h1.large { font-size: 34px; font-weight: 700; margin: 8px 4px 16px; letter-spacing: 0.2px; }
.subtitle { color: var(--muted); font-size: 15px; margin: -10px 4px 16px; }
.section-title { color: var(--muted); font-size: 13px; text-transform: uppercase; margin: 24px 16px 6px; }
.footnote { color: var(--muted); font-size: 13px; margin: 6px 16px 0; }

.card { background: var(--card); border-radius: 12px; overflow: hidden; }
.card + .card { margin-top: 16px; }
.pad { padding: 14px 16px; }

/* リスト */
ul.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 16px; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 52px; right: 0; height: 0.5px; background: var(--sep); }
.row .title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row.done .title { color: var(--muted); text-decoration: line-through; }
.row .meta { color: var(--muted); font-size: 15px; white-space: nowrap; }
.row .meta.late { color: var(--red); }
.row.nav { cursor: pointer; }
.row .chev { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 22px 16px; }

/* 丸いチェック */
.check {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--muted); display: grid; place-items: center;
}
.check.on { background: var(--blue); border-color: var(--blue); }
.check.on::after {
  content: ""; width: 7px; height: 12px; margin-top: -2px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}

/* ステータス */
.status { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status .big { font-size: 28px; font-weight: 700; }
.pill { display: inline-block; border-radius: 999px; padding: 3px 12px; font-size: 15px; font-weight: 600; color: #fff; }
.pill.ok { background: var(--green); }
.pill.late { background: var(--red); }
.pill.done { background: var(--blue); }
.detail { color: var(--muted); font-size: 15px; margin-top: 6px; }
.badge { display: inline-flex; align-items: center; gap: 8px; background: var(--red); color: #fff; border-radius: 999px; padding: 4px 14px; font-weight: 600; font-size: 15px; }

/* 進捗バー */
.progress { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; background: var(--blue); border-radius: 4px; }

/* セグメント */
.segmented { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin: 0 0 16px; }
.segmented button { flex: 1; padding: 6px 8px; border-radius: 7px; font-size: 14px; font-weight: 500; }
.segmented button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18); font-weight: 600; }

/* ボタン */
.btn-row { color: var(--blue); width: 100%; text-align: left; padding: 13px 16px; }
.btn-row.danger { color: var(--red); }
.btn-row + .btn-row { border-top: 0.5px solid var(--sep); }
.nav-actions { display: flex; justify-content: flex-end; margin: -46px 4px 12px; }
.link { color: var(--blue); font-size: 17px; padding: 8px; }
.icon-btn { width: 32px; height: 32px; border-radius: 50%; color: var(--blue); font-size: 18px; }
.icon-btn:disabled { color: var(--muted); opacity: 0.4; }
.del { width: 24px; height: 24px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 700; line-height: 24px; text-align: center; flex: none; }

/* フォーム */
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; min-height: 48px; }
.field + .field { border-top: 0.5px solid var(--sep); }
.field input { text-align: right; background: transparent; border: 0; outline: 0; max-width: 55%; }
.field input[type="number"] { width: 90px; }
.login { display: grid; gap: 14px; margin-top: 18vh; }
.login input { width: 100%; padding: 14px 16px; border-radius: 12px; border: 0; background: var(--card); font-size: 17px; }
.login .primary { background: var(--blue); color: #fff; border-radius: 12px; padding: 14px; font-weight: 600; }
.error { color: var(--red); font-size: 15px; min-height: 1.4em; }

/* ホーム: 広い画面はカレンダー左・その他右、狭い画面は縦並び */
.screen.wide { max-width: 1040px; }
.home-grid { display: grid; gap: 16px; }
.home-side > .card:first-child { margin-top: 0; }
@media (min-width: 720px) {
  .home-grid { grid-template-columns: minmax(320px, 1.1fr) 1fr; align-items: start; }
}

/* カレンダー */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-size: 19px; font-weight: 700; }
.cal-head .icon-btn { font-size: 26px; line-height: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dow { font-size: 12px; color: var(--muted); padding: 4px 0; }
.dow.sun, .day.sun .d { color: var(--red); }
.dow.sat, .day.sat .d { color: var(--blue); }
.day { display: grid; justify-items: center; align-content: start; gap: 1px; min-height: 52px; padding: 5px 0; border-radius: 10px; }
.day.empty { visibility: hidden; }
.day .d { width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-size: 16px; }
.day.today .d { background: var(--red); color: #fff; font-weight: 600; }
.day.selected { background: var(--fill); }
.day .n { font-size: 12px; font-weight: 600; min-height: 15px; }
.day .n.pending { color: var(--blue); }
.day .n.late { color: var(--red); }
.day .n.done { color: var(--green); }

/* タブバー */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: var(--tabbar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--sep);
  padding: 6px 0 calc(env(safe-area-inset-bottom) + 4px);
}
.tabbar-inner { display: flex; width: 100%; max-width: 640px; }
.tab { flex: 1; display: grid; justify-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); padding: 4px 0; }
.tab svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--blue); }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%);
  background: rgba(60, 60, 67, 0.95); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; z-index: 20; max-width: 90vw;
}
