*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{font-size:16px;-webkit-text-size-adjust:100%}
body{font-family:-apple-system,BlinkMacSystemFont,"Helvetica Neue","Hiragino Sans","Noto Sans JP",sans-serif;line-height:1.6;color:#222;background:#f5f5f5;min-height:100dvh}
button{font:inherit;cursor:pointer;touch-action:manipulation}
.btn{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:8px 20px;border:none;border-radius:8px;font-size:1rem;font-weight:600;transition:background .15s}
.btn-primary{background:#e53935;color:#fff}
.btn-primary:active{background:#c62828}
.btn-secondary{background:#43a047;color:#fff}
.btn-secondary:active{background:#2e7d32}
.btn-resolve{background:#1e88e5;color:#fff}
.btn-resolve:active{background:#1565c0}
.btn-outline{background:transparent;border:2px solid #888;color:#444}
.btn-outline:active{background:#eee}
.btn-sm{min-height:36px;padding:4px 12px;font-size:.875rem}
#app{max-width:480px;margin:0 auto;padding:0 0 80px}
header{position:sticky;top:0;z-index:10;background:#fff;padding:12px 16px;border-bottom:1px solid #ddd}
header h1{font-size:1.1rem;font-weight:700}
header h1 a{color:inherit;text-decoration:none}
.header-meta{font-size:.8rem;color:#888;margin-top:2px}
.header-actions{display:flex;gap:8px;margin-top:8px}
.btn-refresh{margin-left:auto}
.incident-list{list-style:none}
.incident-item{background:#fff;margin:8px 12px;padding:12px 16px;border-radius:10px;box-shadow:0 1px 3px rgba(0,0,0,.08);cursor:pointer}
.incident-item:active{background:#f5f5f5}
.incident-item-header{display:flex;justify-content:space-between;align-items:flex-start}
.incident-place{font-weight:700;font-size:1rem}
.incident-distance{font-size:.8rem;color:#888}
.incident-category{margin-top:4px;font-size:.95rem}
.incident-meta{display:flex;gap:8px;margin-top:6px;font-size:.8rem;color:#888;flex-wrap:wrap}
.badge{display:inline-block;padding:2px 8px;border-radius:4px;font-size:.75rem;font-weight:600}
.badge-0{background:#e0e0e0;color:#666}
.badge-1{background:#fff3e0;color:#e65100}
.badge-2{background:#e8f5e9;color:#2e7d32}
.badge-3{background:#e3f2fd;color:#1565c0}
.badge-4{background:#fce4ec;color:#c62828}
.form-section{padding:16px}
.form-group{margin-bottom:16px}
.form-group label{display:block;font-weight:600;margin-bottom:4px;font-size:.9rem}
.form-group select,.form-group input,.form-group textarea{width:100%;padding:10px 12px;border:1px solid #ccc;border-radius:8px;font-size:1rem;min-height:44px;background:#fff;font-family:inherit}
.form-group textarea{min-height:80px;resize:vertical}
.qty-row{display:flex;gap:8px}
.qty-row input[type=number]{flex:1;min-width:0}
.qty-row select{flex:0 0 110px}
.form-actions{display:flex;gap:8px;margin-top:20px}
.form-actions .btn{flex:1}
.location-consent{background:#f7f8fa;border:1px solid #e0e2e6;border-radius:8px;padding:10px 12px}
.consent-label{display:flex;align-items:flex-start;gap:8px;font-weight:600;font-size:.9rem;margin:0}
.consent-label input[type=checkbox]{width:auto;min-height:auto;margin-top:2px;accent-color:#e53935}
.consent-note{font-size:.8rem;color:#777;margin:6px 0 0}
.card{background:#fff;margin:12px;padding:16px;border-radius:10px;box-shadow:0 1px 3px rgba(0,0,0,.08)}
.detail-row{display:flex;justify-content:space-between;padding:6px 0;border-bottom:1px solid #eee;font-size:.9rem}
.detail-row:last-child{border-bottom:none}
.detail-label{color:#888}
.history-item{padding:8px 0;border-bottom:1px solid #eee;font-size:.85rem}
.history-item:last-child{border-bottom:none}
.empty{text-align:center;padding:40px 20px;color:#888}
.empty p{margin-top:8px;font-size:.9rem}
.toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);background:#333;color:#fff;padding:10px 20px;border-radius:8px;font-size:.9rem;z-index:100;animation:in .3s ease}
@keyframes in{from{opacity:0;transform:translateX(-50%) translateY(10px)}to{opacity:1;transform:translateX(-50%) translateY(0)}}
.spinner{width:24px;height:24px;border:3px solid #ddd;border-top-color:#e53935;border-radius:50%;animation:spin .6s linear infinite;margin:20px auto}
@keyframes spin{to{transform:rotate(360deg)}}
.brand{display:block;color:#e53935;font-weight:700;font-size:1.1rem;text-decoration:none;cursor:pointer;margin-bottom:8px}
.brand:hover{text-decoration:underline}
@media(min-width:768px){#app{max-width:640px}}

/* ---------- 地図 (Leaflet/OpenStreetMap) ---------- */
.map-wrap{height:200px;border-radius:10px;overflow:hidden;border:1px solid #e0e2e6;background:#eef1f4;z-index:1;margin:0 12px}
.dsl-marker{background:transparent;border:none}
.dsl-marker .dot{display:block;width:14px;height:14px;border-radius:50%;border:2px solid #fff;box-shadow:0 0 4px rgba(0,0,0,.5)}
.dsl-marker .pin{display:block;width:16px;height:16px;border-radius:50% 50% 50% 0;background:#0f172a;transform:rotate(-45deg);border:2px solid #fff;box-shadow:0 0 4px rgba(0,0,0,.5)}
.dsl-marker .user-dot{display:block;width:12px;height:12px;border-radius:50%;background:#2563eb;border:2px solid #fff;box-shadow:0 0 0 3px rgba(37,99,235,.3)}
.map-toggle{display:block;width:100%;padding:8px;margin:0 0 8px;border:1px solid #e0e2e6;border-radius:8px;background:#fff;font-size:.85rem;color:#555;cursor:pointer}
.map-notice{background:#f7f8fa;border:1px solid #e0e2e6;border-radius:10px;padding:14px;font-size:.85rem;color:#777;margin-bottom:8px}
.leaflet-container{font-family:inherit}

/* ---------- カテゴリ絞り込み / タブ ---------- */
.chip-row{display:flex;gap:5px;padding:10px 12px 0;flex-wrap:wrap}
.chip{flex:0 0 auto;padding:5px 10px;border-radius:16px;border:1px solid #ccc;background:#fff;font-size:.75rem;color:#555;cursor:pointer;white-space:nowrap}
.chip.active{background:#e53935;border-color:#e53935;color:#fff}
.tab-row{display:flex;gap:8px;padding:10px 12px 4px}
.tab{flex:1;text-align:center;padding:8px;border-radius:8px;border:1px solid #ccc;background:#fff;font-size:.85rem;font-weight:600;color:#555;cursor:pointer}
.tab.active{background:#0f766e;border-color:#0f766e;color:#fff}
.origin-bar{display:flex;align-items:center;gap:8px;padding:8px 12px;font-size:.8rem;color:#555}
.origin-bar .origin-name{flex:1;color:#333;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.incident-distance{font-weight:700;color:#0f766e}

/* ---------- おすそわけ ---------- */
.surplus-tag{display:inline-block;background:#e6f4ea;color:#1e7e34;border-radius:4px;padding:1px 6px;font-size:.72rem;font-weight:700;margin-right:6px}
.surplus-qty{color:#1e7e34;font-weight:700}
.match-card{background:#f0fdf4;border:1px solid #bbe7c9;border-radius:10px;padding:12px;margin:8px 12px}
.match-card h3{font-size:.9rem;margin-bottom:6px;color:#1e7e34}
.match-item{padding:8px 0;border-bottom:1px dashed #d4e8d9;font-size:.85rem}
.match-item:last-child{border-bottom:none}
.match-item .dist{color:#0f766e;font-weight:700}
.walk-note{font-size:.75rem;color:#777;margin-top:2px}

/* ---------- ジオサーチ ---------- */
.geo-box{padding:10px 12px}
.geo-box .geo-row{display:flex;gap:6px;margin-bottom:6px}
.geo-box input[type=text],.geo-box input[type=tel]{flex:1;padding:8px 10px;border:1px solid #ccc;border-radius:8px;font-size:.9rem;min-height:40px;background:#fff}
.geo-results{max-height:180px;overflow-y:auto;border:1px solid #e0e2e6;border-radius:8px;background:#fff;margin-top:6px}
.geo-result-item{padding:8px 10px;border-bottom:1px solid #eee;font-size:.82rem;cursor:pointer}
.geo-result-item:last-child{border-bottom:none}
.geo-result-item:active{background:#f0f7ff}
.geo-result-item .r-name{font-weight:600;color:#0b3d91}
.geo-result-item .r-sub{color:#777;font-size:.75rem;margin-top:1px}
.geo-hint{font-size:.72rem;color:#888;margin-top:4px}
.geo-error{font-size:.78rem;color:#c62828;margin-top:4px}
.geo-empty{font-size:.78rem;color:#888;padding:8px 10px}
.selected-place{background:#eef6ff;border:1px solid #bcd8f7;border-radius:8px;padding:8px 10px;font-size:.85rem;margin-top:8px}
.altitude-badge{display:inline-flex;align-items:center;gap:4px;background:#fff8e1;color:#b45309;border:1px solid #f0d9a8;border-radius:12px;padding:2px 10px;font-size:.75rem;font-weight:700}
.legend{display:flex;flex-wrap:wrap;gap:8px;padding:6px 12px 0;font-size:.72rem;color:#666}
.legend span{display:inline-flex;align-items:center;gap:4px}
.legend i{display:inline-block;width:10px;height:10px;border-radius:50%;border:1px solid #fff;box-shadow:0 0 2px rgba(0,0,0,.4)}

/* ---------- 状態の見方 ---------- */
.status-legend{background:#fff;margin:12px;padding:16px;border-radius:10px;box-shadow:0 1px 3px rgba(0,0,0,.08)}
.status-legend h2{font-size:.9rem;margin-bottom:4px}
.sl-row{display:flex;align-items:flex-start;gap:8px;padding:7px 0;border-bottom:1px solid #eee;font-size:.8rem;color:#444}
.sl-row:last-of-type{border-bottom:none}
.sl-row .badge{flex:0 0 auto;margin-top:2px}
.sl-note{font-size:.75rem;color:#777;margin-top:8px;padding-top:8px;border-top:1px solid #eee}
