:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2563eb; --accent-ink: #fff; --warn: #b45309; --warn-bg: #fef3c7; --err: #b91c1c; --ok: #15803d;
  --nav-w: 232px; --radius: 10px;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h2 { font-size: 18px; } h3 { font-size: 16px; } h4 { font-size: 14px; margin: 12px 0 6px; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12px; } .error { color: var(--err); min-height: 1em; margin: 0; }
.ico { width: 20px; height: 20px; flex: none; vertical-align: middle; }

/* ログイン */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 360px; background: var(--panel); padding: 28px 24px; border-radius: 14px; border: 1px solid var(--line); display: grid; gap: 12px; }

/* 枠 */
.shell { display: flex; height: 100%; }
.nav { width: var(--nav-w); background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; flex: none; }
.nav-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
.brand { font-weight: 700; font-size: 17px; }
#nav-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
#nav-list a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 14px; }
#nav-list a:hover { background: #f1f5f9; }
#nav-list a.active { background: #eff6ff; color: var(--accent); font-weight: 600; }
#nav-list .count { margin-left: auto; background: var(--err); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 6px; }
#nav-list hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.nav-foot { border-top: 1px solid var(--line); padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); font-size: 13px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar h2 { flex: 1; }
.view { flex: 1; overflow-y: auto; padding: 16px; }
.view.full { padding: 0; overflow: hidden; position: relative; }
.only-narrow { display: none; }
.nav-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 40; }

@media (max-width: 860px) {
  .only-narrow { display: inline-flex; }
  .nav { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .nav.open { transform: none; }
}

/* 部品 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; min-height: 38px; text-decoration: none; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: #f1f5f9; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 10px; }
.card.clickable { cursor: pointer; } .card.clickable:hover { border-color: #cbd5e1; }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head h3 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: #f1f5f9; color: var(--ink); white-space: nowrap; }
.kind-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #f1f5f9; }
.badge.warn { background: var(--warn-bg); color: var(--warn); cursor: pointer; }
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.unread { background: #fee2e2; color: var(--err); }
.list { list-style: none; margin: 0; padding: 0; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
table.tbl { width: 100%; border-collapse: collapse; background: var(--panel); font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12px; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search], .toolbar input[type=text] { flex: 1; min-width: 160px; }

/* フォーム */
form.form { display: grid; gap: 10px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 14px; }
input, select, textarea { font: inherit; color: var(--ink); padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; width: 100%; min-height: 38px; }
label.check input { width: auto; min-height: 0; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--accent); }
.two { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .two { grid-template-columns: 1fr; } }
details > summary { cursor: pointer; color: var(--accent); font-size: 14px; }

/* 地図 */
#map { position: absolute; inset: 0; }
.map-tools { position: absolute; z-index: 500; top: 12px; left: 56px; right: 12px; display: flex; gap: 8px; }
.map-tools input { flex: 1; box-shadow: 0 1px 4px rgba(0,0,0,.15); border: 0; }
.fab-col { position: absolute; z-index: 500; right: 14px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 10px; }
.fab { width: 50px; height: 50px; border-radius: 50%; border: 0; background: var(--panel); color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.2); display: grid; place-items: center; cursor: pointer; }
.fab.primary { background: var(--accent); color: #fff; }
.map-hint { position: absolute; z-index: 500; left: 12px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: rgba(255,255,255,.92); padding: 4px 10px; border-radius: 8px; font-size: 12px; color: var(--muted); max-width: calc(100% - 100px); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; }

/* シート（下から出る／中央） */
.sheet { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.35); }
.sheet-body { position: relative; background: var(--panel); width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; border-radius: 14px 14px 0 0; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 861px) { .sheet { align-items: center; } .sheet-body { border-radius: 14px; } }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.sheet-head h3 { flex: 1; }

/* タイムライン */
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 12px; }
.timeline li::before { content: ""; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--panel); border: 2px solid var(--accent); }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .body { white-space: pre-wrap; }

/* 棒グラフ */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.bars-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.meter { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; min-width: 80px; }
.meter i { display: block; height: 100%; background: var(--accent); }

.toast { position: fixed; z-index: 1100; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); }
.prose { max-width: 720px; } .prose p, .prose li { color: var(--ink); }
.pre { white-space: pre-wrap; }
.preview-img { max-width: 100%; max-height: 220px; border-radius: 8px; border: 1px solid var(--line); }

/* 地図＋周辺の一覧 */
.view.map-view { display: flex; flex-direction: column; }
#map-wrap { position: relative; flex: 1; min-height: 200px; }
.near-panel { flex: none; height: 42vh; display: flex; flex-direction: column; background: var(--panel); border-top: 1px solid var(--line); transition: height .2s; }
.near-panel.closed { height: calc(48px + env(safe-area-inset-bottom, 0px)); }
.near-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.near-head select { width: auto; min-height: 30px; padding: 2px 8px; }
.near-list { flex: 1; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom, 0px); }
.near-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.near-row:hover { background: #f8fafc; }
.near-main { flex: 1; min-width: 0; }
.near-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-view .fab-col, .map-view .map-hint { bottom: 14px; }
.btn.rec-on { background: #fee2e2; border-color: #fca5a5; color: var(--err); }

/* 日報の自動の部分（活動から作る・読むだけ） */
.report-auto { white-space: pre-wrap; font: inherit; font-size: 13px; line-height: 1.6; background: var(--bg, #f6f7f9); border: 1px solid var(--line, #e5e7eb); border-radius: 8px; padding: 10px 12px; margin: 8px 0; max-height: 40vh; overflow: auto; }
.bk-how th { white-space: nowrap; text-align: left; font-weight: 600; } .bk-how { margin: 6px 0 10px; }
