/* KOSMO お仕事マップ — map-first UI (independent from おしごとスワイプ) */
:root {
  --navy-900: #1b2238;
  --navy: #252f4b;
  --navy-600: #3a4566;
  --pink: #c8405b;
  --pink-500: #e0566f;
  --pink-50: #fff1f4;
  --pink-100: #ffe1e7;
  --ink: #1f2430;
  --ink-2: #4a5160;
  --ink-3: #5f6675;
  --line: #e3e6ee;
  --bg: #f4f5f8;
  --card: #fff;
  --blue: #1f6feb;
  --green: #137a5d;
  --radius: 16px;
  --shadow-1: 0 1px 2px rgba(20, 28, 50, 0.06), 0 2px 8px rgba(20, 28, 50, 0.06);
  --shadow-2: 0 10px 30px rgba(20, 28, 50, 0.16);
  --top-h: 60px;
  --chips-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { overflow: hidden; font-size: 14px; line-height: 1.6; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 2000; background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 10px; text-decoration: none; }
.skip-link:focus { top: 8px; }
.noscript { position: fixed; inset: 40% 16px auto; background: #fff; padding: 16px; border-radius: 12px; text-align: center; }

.app { height: 100vh; height: 100dvh; display: grid; grid-template-rows: var(--top-h) var(--chips-h) minmax(0, 1fr); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--navy); color: #fff; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; flex: none; }
.brand img { height: 26px; width: auto; background: #fff; border-radius: 6px; padding: 3px 6px; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: 0.04em; white-space: nowrap; }
.search { position: relative; flex: 1 1 auto; max-width: 560px; display: flex; align-items: center; }
.search-icon { position: absolute; left: 12px; color: var(--ink-3); pointer-events: none; }
.search input { width: 100%; height: 40px; border: 0; border-radius: 999px; padding: 0 40px 0 40px; background: #fff; color: var(--ink); font-size: 14px; }
.search input::placeholder { color: #6b7180; }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { position: absolute; right: 4px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); display: grid; place-items: center; }
.search-clear svg { width: 18px; height: 18px; }
.locate-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.08); color: #fff; font-weight: 700; white-space: nowrap; }
.locate-btn:hover { background: rgba(255, 255, 255, 0.16); }
.locate-btn[aria-pressed="true"] { background: #fff; color: var(--navy); }

/* ---------- category chips ---------- */
.chips { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 14px; background: #fff; border-bottom: 1px solid var(--line); z-index: 15; min-width: 0; }
.chips-scroll { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; padding: 8px 0; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 13px; font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.chip small { font-weight: 600; color: var(--ink-3); font-size: 11.5px; }
.chip:hover { border-color: #c9cede; }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip[aria-pressed="true"] small { color: #d9def0; }
.filter-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-weight: 800; font-size: 13px; color: var(--navy); }
.filter-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--pink); color: #fff; font-size: 11.5px; display: inline-grid; place-items: center; }

/* ---------- workspace ---------- */
.workspace { position: relative; min-height: 0; display: grid; grid-template-columns: 1fr; }
.map-wrap { position: relative; min-height: 0; grid-area: 1 / 1; }
.map { position: absolute; inset: 0; background: #e8ecf2; }
.panel { grid-area: 1 / 1; z-index: 600; background: var(--card); display: flex; flex-direction: column; min-height: 0; }
.list-view { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.result-count { margin: 0; font-weight: 800; font-size: 14px; color: var(--navy); }
.result-count b { font-size: 18px; color: var(--pink); margin: 0 2px; }
.result-tools { display: flex; align-items: center; gap: 10px; }
.area-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.area-toggle input { width: 16px; height: 16px; accent-color: var(--navy); margin: 0; }
#sortSelect { height: 34px; border: 1px solid var(--line); border-radius: 9px; padding: 0 8px; background: #fff; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.place-filter { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 10px 16px 0; padding: 8px 12px; border-radius: 10px; background: var(--pink-50); color: var(--pink); font-weight: 700; font-size: 13px; }
.place-filter button { border: 0; background: #fff; color: var(--pink); border-radius: 8px; padding: 4px 10px; font-weight: 800; font-size: 12px; }
.result-list { list-style: none; margin: 0; padding: 8px 10px 24px; overflow-y: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.result-list:focus { outline: none; }

/* job row */
.job { position: relative; }
.job + .job { margin-top: 8px; }
.job-btn { width: 100%; display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; align-items: start; text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: #fff; transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s; }
.job-btn:hover { border-color: #c6ccdb; box-shadow: var(--shadow-1); }
.job.is-active .job-btn { border-color: var(--pink-500); box-shadow: 0 0 0 2px var(--pink-100); background: #fffafb; }
.thumb { position: relative; width: 104px; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: linear-gradient(135deg, #eef1f7, #e2e7f0); }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.25s; }
.thumb img.is-loaded { opacity: 1; }
.thumb-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: #8790a3; font-size: 11px; font-weight: 800; letter-spacing: 0.05em; }
.job-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.job-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; font-weight: 700; color: var(--ink-3); }
.cat { color: var(--navy-600); background: #eef1f8; border-radius: 6px; padding: 1px 7px; }
.job-title { margin: 0; font-size: 14px; font-weight: 800; line-height: 1.45; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.job-wage { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.job-wage strong { font-size: 17px; color: var(--pink); font-weight: 800; letter-spacing: -0.01em; }
.job-place { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 3px; min-width: 0; }
.job-place svg { width: 14px; height: 14px; }
.job-place span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dist { color: var(--blue); font-weight: 800; white-space: nowrap; }
.feat-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.feat { font-size: 11px; font-weight: 700; color: var(--green); background: #e8f5ef; border-radius: 6px; padding: 1px 6px; }
.save-btn { position: absolute; top: 14px; left: 14px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, 0.94); color: var(--ink-3); display: grid; place-items: center; box-shadow: var(--shadow-1); }
.save-btn svg { width: 18px; height: 18px; }
.save-btn[aria-pressed="true"] { color: var(--pink); }
.save-btn[aria-pressed="true"] svg { fill: currentColor; }

.empty { padding: 36px 24px; text-align: center; color: var(--ink-2); }
.empty-title { font-weight: 800; color: var(--navy); font-size: 15px; margin: 0 0 4px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.ghost-btn { height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 800; color: var(--navy); }
.primary-btn { height: 44px; padding: 0 22px; border-radius: 999px; border: 0; background: var(--pink); color: #fff; font-weight: 800; }
.primary-btn:hover { background: #b23650; }

/* ---------- detail ---------- */
.detail-view { overflow-y: auto; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.detail-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: rgba(255, 255, 255, 0.96); border-bottom: 1px solid var(--line); }
.back-btn { display: inline-flex; align-items: center; gap: 4px; height: 38px; padding: 0 12px 0 6px; border: 0; border-radius: 999px; background: transparent; font-weight: 800; color: var(--navy); }
.back-btn:hover { background: var(--bg); }
.detail-actions-top { display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn[aria-pressed="true"] { color: var(--pink); border-color: var(--pink-100); background: var(--pink-50); }
.icon-btn[aria-pressed="true"] svg { fill: currentColor; }
.detail-photo { position: relative; aspect-ratio: 4 / 3; background: linear-gradient(135deg, #eef1f7, #e2e7f0); overflow: hidden; }
.detail-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-body { padding: 16px 18px 28px; }
.detail-body h2 { margin: 6px 0 6px; font-size: 19px; line-height: 1.45; color: var(--ink); }
.detail-catch { margin: 0 0 10px; color: var(--ink-2); font-size: 13px; }
.detail-wage { margin: 6px 0 12px; font-weight: 700; color: var(--ink-2); }
.detail-wage strong { font-size: 26px; color: var(--pink); letter-spacing: -0.02em; }
.facts { margin: 0; display: grid; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.facts > div { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 10px; padding: 10px 12px; }
.facts > div + div { border-top: 1px solid var(--line); }
.facts dt { font-size: 12px; font-weight: 800; color: var(--ink-3); }
.facts dd { margin: 0; font-size: 13px; white-space: pre-line; overflow-wrap: anywhere; }
.precision-note { font-size: 11.5px; color: var(--ink-3); margin: 8px 2px 0; }
.detail-cta { display: grid; gap: 8px; margin-top: 18px; }
.detail-cta a { display: flex; align-items: center; justify-content: center; gap: 6px; height: 48px; border-radius: 999px; text-decoration: none; font-weight: 800; }
.cta-primary { background: var(--pink); color: #fff; }
.cta-primary:hover { background: #b23650; }
.cta-secondary { border: 1px solid var(--line); color: var(--navy); background: #fff; }
.nearby { margin-top: 22px; }
.nearby h3 { font-size: 14px; margin: 0 0 8px; color: var(--navy); }
.nearby ul { list-style: none; margin: 0; padding: 0; }

/* ---------- map overlays ---------- */
.map-fab { position: absolute; right: 12px; top: 12px; z-index: 500; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 999px; border: 0; background: #fff; box-shadow: var(--shadow-1); font-weight: 800; font-size: 12.5px; color: var(--navy); }
.map-status { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 500; background: var(--navy); color: #fff; padding: 7px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 700; box-shadow: var(--shadow-1); white-space: nowrap; }
.map-legend { position: absolute; left: 10px; bottom: 26px; z-index: 450; display: flex; gap: 10px; background: rgba(255, 255, 255, 0.92); border-radius: 10px; padding: 5px 10px; font-size: 11px; font-weight: 700; color: var(--ink-2); box-shadow: var(--shadow-1); }
.map-legend span { display: inline-flex; align-items: center; gap: 4px; }
.lg-pin { width: 18px; height: 10px; border-radius: 4px; background: var(--navy); display: inline-block; }
.lg-cluster { width: 12px; height: 12px; border-radius: 50%; background: var(--pink); display: inline-block; }

/* price-tag markers */
.leaflet-div-icon.pin-icon, .leaflet-div-icon.cluster-icon, .leaflet-div-icon.me-icon { background: transparent; border: 0; }
.pin { position: absolute; left: 0; bottom: 0; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 3px; height: 28px; padding: 0 9px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 12.5px; font-weight: 800; white-space: nowrap; box-shadow: 0 2px 6px rgba(20, 28, 50, 0.35); border: 2px solid #fff; transition: transform 0.12s, background-color 0.12s; }
.pin::after { content: ""; position: absolute; left: 50%; bottom: -7px; width: 10px; height: 10px; background: inherit; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: translateX(-50%) rotate(45deg); border-radius: 0 0 3px 0; }
.pin em { font-style: normal; font-size: 11px; background: rgba(255, 255, 255, 0.22); border-radius: 999px; padding: 0 5px; }
.pin.saved::before { content: "♥"; color: #ffb3c2; font-size: 11px; }
.pin-icon:hover .pin, .pin-icon:focus-visible .pin { background: var(--navy-600); transform: translateX(-50%) scale(1.06); }
.pin-icon.is-active { z-index: 1000 !important; }
.pin-icon.is-active .pin { background: var(--pink); transform: translateX(-50%) scale(1.12); }
.pin-icon.is-dim .pin { background: #8a92a6; }
.pin-icon:focus-visible { outline: none; }
.pin-icon:focus-visible .pin { outline: 3px solid var(--blue); outline-offset: 2px; }
.cluster { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); display: grid; place-items: center; border-radius: 50%; background: var(--pink); color: #fff; font-weight: 800; border: 3px solid rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 6px rgba(200, 64, 91, 0.22), 0 3px 10px rgba(20, 28, 50, 0.25); line-height: 1.05; text-align: center; }
.cluster small { display: block; font-size: 9.5px; font-weight: 700; opacity: 0.92; }
.cluster.s { width: 44px; height: 44px; font-size: 14px; }
.cluster.m { width: 54px; height: 54px; font-size: 16px; }
.cluster.l { width: 66px; height: 66px; font-size: 18px; }
.cluster-icon:focus-visible { outline: none; }
.cluster-icon:focus-visible .cluster { outline: 3px solid var(--blue); outline-offset: 3px; }
.me { position: absolute; left: 0; top: 0; width: 18px; height: 18px; transform: translate(-50%, -50%); border-radius: 50%; background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 0 8px rgba(31, 111, 235, 0.2); }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10.5px; }
.leaflet-control-attribution a { color: #24508f; }
.leaflet-control-zoom a { color: var(--navy); }

/* ---------- filter dialog ---------- */
.filter-dialog { border: 0; padding: 0; border-radius: 20px; width: min(560px, calc(100vw - 24px)); max-height: min(86dvh, 760px); box-shadow: var(--shadow-2); color: var(--ink); }
.filter-dialog::backdrop { background: rgba(20, 26, 44, 0.45); }
.filter-dialog form { display: flex; flex-direction: column; max-height: inherit; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 17px; color: var(--navy); }
.dialog-body { overflow-y: auto; padding: 6px 20px 12px; }
fieldset { border: 0; margin: 0; padding: 14px 0 6px; }
fieldset + fieldset { border-top: 1px solid var(--line); }
legend { font-weight: 800; font-size: 14px; color: var(--navy); padding: 0; margin-bottom: 8px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label, .checks .check { position: relative; }
.seg input, .checks input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span, .checks span { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.checks span small { color: var(--ink-3); font-weight: 600; }
.seg input:checked + span, .checks input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.checks input:checked + span small { color: #d9def0; }
.seg input:focus-visible + span, .checks input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.dialog-foot { display: flex; justify-content: space-between; gap: 10px; padding: 12px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); }
.dialog-foot .primary-btn { flex: 1 1 auto; max-width: 280px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); z-index: 3000; background: var(--navy-900); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 700; box-shadow: var(--shadow-2); max-width: calc(100vw - 32px); }

/* ---------- desktop: side panel + map ---------- */
@media (min-width: 960px) {
  :root { --top-h: 64px; }
  .workspace { grid-template-columns: 420px minmax(0, 1fr); }
  .panel { grid-area: 1 / 1; border-right: 1px solid var(--line); box-shadow: 4px 0 18px rgba(20, 28, 50, 0.05); }
  .map-wrap { grid-area: 1 / 2; }
  .sheet-handle { display: none; }
  .chips { padding-left: 18px; }
  .topbar { padding: 0 18px; gap: 18px; }
}
@media (min-width: 1400px) {
  .workspace { grid-template-columns: 460px minmax(0, 1fr); }
}

/* ---------- mobile: bottom sheet over full map ---------- */
@media (max-width: 959px) {
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; top: 0;
    border-radius: 20px 20px 0 0; box-shadow: 0 -6px 24px rgba(20, 28, 50, 0.16);
    transform: translateY(calc(100% - var(--peek, 150px)));
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    will-change: transform;
  }
  .panel[data-sheet="half"] { transform: translateY(46%); }
  .panel[data-sheet="full"] { transform: translateY(0); border-radius: 0; }
  .panel.is-dragging { transition: none; }
  .sheet-handle { flex: none; display: grid; place-items: center; height: 22px; cursor: grab; touch-action: none; }
  .sheet-handle span { width: 42px; height: 5px; border-radius: 999px; background: #c9cedb; }
  .result-head { padding-top: 2px; touch-action: none; }
  .map-legend { display: none; }
  .panel { z-index: 1100; }
  .leaflet-control-zoom { display: none; }
  .map-fab { top: 10px; right: 10px; height: 36px; }
  .map-status { top: 54px; left: 10px; right: 10px; transform: none; white-space: normal; text-align: center; border-radius: 12px; }
  .panel:not([data-sheet="full"]) .detail-view, .panel:not([data-sheet="full"]) .result-list { padding-bottom: calc(48% + 24px); }
  .panel:not([data-sheet]) .detail-view, .panel:not([data-sheet]) .result-list { padding-bottom: 24px; }
  .leaflet-bottom { bottom: var(--peek, 150px); }
}
@media (max-width: 520px) {
  .brand-name { display: none; }
  .brand img { height: 24px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .locate-btn { padding: 0 11px; }
  .locate-btn span { display: none; }
  .search input { font-size: 16px; padding-right: 36px; }
  .search input::placeholder { font-size: 13px; }
  .result-tools { width: 100%; justify-content: space-between; }
  .job-btn { grid-template-columns: 92px minmax(0, 1fr); gap: 10px; }
  .thumb { width: 92px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
