/* モノクロ基調。色を使うのはメンバーのルートだけ。 */
:root {
  --bg: #ffffff;
  --bg-subtle: #fafafa;
  --bg-hover: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text-faint: #a1a1aa;
  --text-muted: #71717a;
  --text: #171717;
  --black: #000000;

  /* メンバーの色（最大 10 人）。1〜5 は Okabe-Ito、6〜10 は Paul Tol の muted などから */
  /* 緑は店舗の点と、黄色は白い背景で見えにくく、灰色は地図（グレースケール）に紛れるので外す */
  --member-1: #0072b2;
  --member-2: #d55e00;
  --member-3: #cc79a7;
  --member-4: #e69f00;
  --member-5: #56b4e9;
  --member-6: #332288;
  --member-7: #882255;
  --member-8: #aa4499;
  --member-9: #cc6677;
  --member-10: #8c564b;
  --store: #00704a;
  --store-out: #c4c4c8;
  --best-bg: #e6f4ec;  /* 最良の案の網掛け（店舗の緑を薄くしたもの） */

  --radius: 6px;
  --font: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: grid;
  grid-template-columns: 540px 1fr;
  height: 100vh;
  min-width: 1100px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px 28px 20px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.header h1 { margin: 0 0 4px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.muted { color: var(--text-muted); margin: 0; }
.num { font-variant-numeric: tabular-nums; }

/* フォーム */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { font-size: 13px; font-weight: 500; color: var(--text); padding: 0; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.row2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }

select, input[type="number"] {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
select:focus, input:focus, button:focus-visible, summary:focus-visible, .plan-row:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 1px;
}
.unit { position: relative; }
.unit input { padding-right: 44px; }
.unit span {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 12px; pointer-events: none;
}
.hint { margin: 0; color: var(--text-muted); font-size: 12px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--black); width: 15px; height: 15px; margin: 0; }

.advanced {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 14px;
}
.advanced[open] { padding-bottom: 14px; }
.advanced > summary {
  cursor: pointer;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  list-style: none;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::before { content: "▸"; display: inline-block; width: 1em; transition: transform .15s; }
.advanced[open] > summary::before { transform: rotate(90deg); }
.advanced > *:not(summary) + * { margin-top: 14px; }
.advanced fieldset { gap: 8px; }

.actions { display: flex; align-items: center; gap: 14px; }
button.primary {
  height: 40px;
  padding: 0 28px;
  border: 1px solid var(--black);
  border-radius: var(--radius);
  background: var(--black);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
button.primary:hover { background: #333; }
button.primary:disabled { background: var(--text-faint); border-color: var(--text-faint); cursor: wait; }

.loading { display: none; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; }
.loading.htmx-request { display: inline-flex; }
.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--black);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 結果パネル */
.result { border-top: 1px solid var(--border); padding-top: 20px; flex: 1 0 auto; }
.placeholder { font-size: 13px; }
.summary { margin: 0 0 12px; color: var(--text-muted); font-size: 13px; }
.summary strong { color: var(--text); font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-weight: 500; color: var(--text-muted); font-size: 12px; }
td.r, th.r { text-align: right; }
td { font-variant-numeric: tabular-nums; }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.table-wrap tbody tr:last-child td { border-bottom: 0; }
.compare td:nth-child(2) { white-space: normal; min-width: 7em; }
.compare th { background: var(--bg-subtle); }

.plan-row { cursor: pointer; transition: background .1s; }
.plan-row:hover { background: var(--bg-hover); }
.plan-row.selected { background: var(--bg-hover); box-shadow: inset 3px 0 0 var(--black); }
.plan-row.best, .plan-row.best:hover { background: var(--best-bg); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.tag {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 12px; font-weight: 600;
}
.plan-row.selected .tag { background: var(--black); border-color: var(--black); color: #fff; }

.members { margin-top: 20px; }
.members h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; }
.swatch {
  display: inline-block; width: 10px; height: 10px; margin-right: 8px;
  border-radius: 50%; background: var(--c); vertical-align: -1px;
}
.note { margin: 8px 0 0; font-size: 13px; }

.message {
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--black);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--bg-subtle);
}
.message p { margin: 0; }

.footer { border-top: 1px solid var(--border); padding-top: 14px; color: var(--text-muted); font-size: 11px; }
.footer p { margin: 0; }

/* 地図 */
.map-wrap { position: relative; }
#map { position: absolute; inset: 0; background: #fff; }
.leaflet-container { font-family: var(--font); }
.tiles-gray { filter: grayscale(1); }
.leaflet-control-layers, .leaflet-bar { border: 1px solid var(--border-strong) !important; box-shadow: none !important; border-radius: var(--radius) !important; }
.stop span {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 0 4px;
  border: 1px solid #fff;
  border-radius: 9px;
  background: var(--c);
  color: #fff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.15);
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 地図の凡例 */
.legend { background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 6px 10px; font-size: 12px; color: var(--text-muted); line-height: 1.7; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
