:root {
  --bg: #f7f5ef;
  --card: #ffffff;
  --text: #2b2b2b;
  --muted: #777;
  --line: #e3dfd4;
  --accent: #4f8f4f;
  --accent-soft: #e6f1e3;
  --tap: 48px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1d1b; --card: #262926; --text: #ececec; --muted: #9a9a9a;
    --line: #3a3d3a; --accent: #7cc07c; --accent-soft: #2f3d2f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input { font: inherit; color: inherit; }

/* ヘッダー */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  padding: env(safe-area-inset-top) 8px 0;
  min-height: 56px; background: var(--card); border-bottom: 1px solid var(--line);
}
.bar h1 { flex: 1; margin: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: var(--tap); height: var(--tap); border: 0; background: none;
  font-size: 26px; line-height: 1; border-radius: 12px; cursor: pointer;
}
.icon-btn:active { background: var(--accent-soft); }

main { max-width: 640px; margin: 0 auto; padding: 16px; }

/* 全体の進捗 */
.overall { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; }
.overall .nums { display: flex; justify-content: space-between; align-items: baseline; }
.overall .big { font-size: 26px; font-weight: 700; }
.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: var(--accent); transition: width .3s; }

.sync-status {
  display: block; width: 100%; min-height: 44px; margin-top: 8px; padding: 0;
  border: 0; background: none; text-align: left; font-size: 13px; color: var(--muted); cursor: pointer;
}
.sync-status::before { content: "●"; margin-right: 6px; color: var(--muted); }
.sync-status[data-state="ok"]::before { color: var(--accent); }
.sync-status[data-state="offline"]::before, .sync-status[data-state="error"]::before { color: #d9a23a; }
.sync-status[data-state="nopass"]::before, .sync-status[data-state="badpass"]::before { color: #d0583c; }
.sync-status[data-state="nopass"], .sync-status[data-state="badpass"] { color: var(--text); }
.pass-form input {
  width: 100%; min-height: 50px; padding: 0 14px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 17px;
}
dialog h2 + .note { margin-top: 0; }
.pass-form + h2 { margin-top: 10px; }

/* 絞り込み */
.filters { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.chip {
  flex: none; min-height: 44px; padding: 0 16px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 路線グループ */
details.line { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden; }
details.line > summary {
  list-style: none; cursor: pointer; min-height: 56px; padding: 10px 16px;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px;
}
details.line > summary::-webkit-details-marker { display: none; }
.line-name { font-weight: 700; }
.line-count { font-variant-numeric: tabular-nums; color: var(--muted); }
.line-count b { color: var(--text); }
summary .progress { grid-column: 1 / -1; height: 6px; margin-top: 4px; }
.done-mark { color: var(--accent); }

ul.stations { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
ul.stations li { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
ul.stations li:last-child { border-bottom: 0; }
.st-link {
  flex: 1; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 8px 16px;
  color: inherit; text-decoration: none;
}
.st-link:active { background: var(--accent-soft); }
.st-name { font-size: 17px; }
.st-kana { color: var(--muted); font-size: 13px; }
.st-arrow { margin-left: auto; color: var(--muted); }
.shot .st-name { color: var(--muted); }

/* チェックボックス（指で押せる大きさ） */
.check { display: flex; align-items: center; justify-content: center; width: 56px; min-height: 56px; cursor: pointer; flex: none; }
.check input { appearance: none; -webkit-appearance: none; margin: 0; width: 28px; height: 28px; border: 2px solid var(--muted); border-radius: 8px; display: grid; place-items: center; cursor: pointer; background: var(--card); }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { content: "✓"; color: #fff; font-size: 18px; font-weight: 700; }

/* 詳細 */
.detail h2 { margin: 0; font-size: 28px; }
.detail .sub { color: var(--muted); margin: 2px 0 12px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.badge { font-size: 13px; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 8px; font-size: 15px; color: var(--muted); font-weight: 600; }
.card p { margin: 0; }
.status-toggle { display: flex; align-items: center; gap: 12px; min-height: 64px; font-size: 18px; font-weight: 700; cursor: pointer; }
.status-toggle .check { width: auto; }
.tip + .tip { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }
.tip-imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.tip-imgs img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--line); }
.tip-imgs img:only-child { grid-column: 1 / -1; aspect-ratio: 16 / 9; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 52px;
  border-radius: 12px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 700;
}
.btn.ghost { background: var(--card); color: var(--accent); border: 1px solid var(--accent); }
.video-link { word-break: break-all; }
.muted { color: var(--muted); }

/* メニュー */
dialog#menu { border: 0; border-radius: 16px; padding: 20px; width: min(92vw, 420px); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog h2 { margin: 0 0 8px; font-size: 18px; }
.note { font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.wide { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 50px; margin-bottom: 10px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.wide.ghost { background: none; color: var(--text); border: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #333; color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 14px; }
