/* Light, high-contrast theme: readable on a tablet in direct sunlight. */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --border: #d1d5db;
  --border-strong: #6b7280;
  --text: #111827;
  --muted: #4b5563;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #e8eefc;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #92400e;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .06);
  --topbar: 56px;
  --sidebar: 232px;
  --gutter: 16px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
}

a { color: var(--primary); text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.35; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.stack { display: grid; gap: 16px; }
.show-sm { display: none; }

/* ── shell ─────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar);
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
/* 未送信: visits saved on the device, waiting for signal (outbox.js). */
.outbox { position: relative; }
.topbar-user .btn { white-space: nowrap; }
.outbox summary { list-style: none; background: var(--warn-soft); border-color: #f5d88a; color: var(--warn); font-weight: 700; }
.outbox summary::-webkit-details-marker { display: none; }
.outbox-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 1100; width: min(320px, calc(100vw - 24px)); padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 2px 8px rgba(17, 24, 39, .25);
}
.outbox-menu p { margin: 0 0 8px; }
.outbox-menu ul { margin: 0 0 10px; display: grid; gap: 6px; }
.user-name { color: var(--muted); font-size: .9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar form { margin: 0; }
.nav-toggle {
  display: none;
  width: 44px; height: 44px; margin-left: -10px;
  align-items: center; justify-content: center;
  background: none; border: 0; border-radius: var(--radius); color: var(--text); cursor: pointer;
}
.nav-toggle .icon { width: 24px; height: 24px; }

.shell { display: flex; min-height: calc(100vh - var(--topbar)); }

.sidebar {
  flex: none; width: var(--sidebar);
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar a {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text); text-decoration: none; font-weight: 500;
}
.sidebar a.nav-end { margin-top: auto; }
.sidebar a:hover { background: var(--surface-alt); }
.sidebar a.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }

.main {
  flex: 1; min-width: 0;
  max-width: 1080px;
  padding: 24px 32px 64px;
}

.back { display: inline-block; margin-bottom: 8px; font-size: .9375rem; text-decoration: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-actions form { margin: 0; }

@media (max-width: 1023px) {
  .nav-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; z-index: 30; top: var(--topbar); bottom: 0; left: 0;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .15s ease, visibility .15s;
  }
  body.nav-open .sidebar { transform: none; visibility: visible; box-shadow: 0 8px 24px rgba(17, 24, 39, .15); }
  body.nav-open::after {
    content: ""; position: fixed; inset: var(--topbar) 0 0 0; z-index: 25;
    background: rgba(17, 24, 39, .3);
  }
  .main { padding: 20px var(--gutter) 64px; }
}

@media (max-width: 599px) {
  h1 { font-size: 1.3125rem; }
  .hide-sm { display: none; }
  .show-sm { display: block; }
  .user-name { display: none; }
}
@media (max-width: 899px) { .hide-md { display: none; } }

/* ── cards, stats, tables ──────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card > h2 { margin-bottom: 12px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }
.card.empty { padding: 40px 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stats .card { margin: 0; }
.stat-label { color: var(--muted); font-size: .9375rem; }
.stats .stat { padding: 16px 20px; }
.stat-value small { margin-left: 8px; font-size: .9375rem; font-weight: 600; color: var(--muted); }
.stat-link { display: block; color: var(--text); text-decoration: none; }
.stat-link:hover { border-color: var(--primary); }
.stat-link.active { border: 2px solid var(--primary); background: var(--primary-soft); padding: 15px 19px; }
.stat-link.active .stat-label { color: var(--primary); font-weight: 700; }
.stat-ok .stat-value { color: var(--ok); }
.num-ok { color: var(--ok); font-weight: 700; }
.filter-chip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; padding: 8px 12px; background: var(--primary-soft); border: 1px solid #c7d5f7; border-radius: var(--radius); }
.outcomes { margin-bottom: 8px; }
.stat-value { font-size: 2.5rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table thead th { font-size: .8125rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table tbody tr:last-child > * { border-bottom: 0; }
.row-muted td { color: var(--muted); }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions form { display: inline; margin: 0 0 0 4px; }

.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 999px; font-size: .8125rem; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: #b7e0c4; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: #f5d88a; }
.badge-muted { background: var(--surface-alt); color: var(--muted); border-color: var(--border); }

/* ── buttons ──────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-alt); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-sm { min-height: 36px; padding: 4px 12px; font-size: .875rem; }
.btn-lg { min-height: 52px; padding: 10px 24px; font-size: 1.0625rem; }
.btn-block { width: 100%; }
:is(.btn, a, input, select, textarea, .choice span):focus-visible { outline: 3px solid #93b4f5; outline-offset: 2px; }

/* ── forms ─────────────────────────────────────────── */

input, select, textarea {
  width: 100%;
  min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 1rem;
}
textarea { min-height: 96px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }

.field { display: grid; gap: 6px; }
.label { font-weight: 600; }
.optional { margin-left: 8px; font-weight: 400; font-size: .8125rem; color: var(--muted); }
.help { display: block; color: var(--muted); font-size: .875rem; }
.error { display: block; color: var(--danger); font-size: .875rem; font-weight: 600; }
.has-error input:not([type=radio]):not([type=checkbox]), .has-error textarea { border-color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 20px; height: 20px; }
.form-card { max-width: 560px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.flash { padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius); border: 1px solid #b7e0c4; background: var(--ok-soft); }
.flash-warn { background: var(--warn-soft); border-color: #f5d88a; }
.flash-error { background: var(--danger-soft); border-color: #f3b9b9; color: var(--danger); }
.flash-error a { color: inherit; font-weight: 700; margin-right: 6px; }
.flash-link { margin-top: 8px; }
.flash-link input { font-size: .875rem; background: var(--surface); }

fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field > legend { padding: 0; margin-bottom: 6px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── search & property picker ──────────────────────── */

.toolbar { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search { flex: 1 1 280px; }
.search input { font-size: 1.0625rem; min-height: 48px; }

.pick-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pick {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 64px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  color: var(--text); text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.pick:hover, .pick:active { border-color: var(--primary); background: var(--primary-soft); }
.pick > span:first-child { display: grid; gap: 2px; min-width: 0; }
.property-name { font-weight: 700; font-size: 1.0625rem; line-height: 1.4; }

.property-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding: 12px 16px;
  background: var(--primary-soft); border: 1px solid #c7d5f7; border-radius: var(--radius);
}

/* ── import review ─────────────────────────────────── */

.tabs-sm { margin-bottom: 12px; }
.tabs-sm a { padding: 8px 12px; font-size: .9375rem; }
.check-col { width: 44px; }
.check-col input { width: 20px; height: 20px; vertical-align: middle; }
.import-rows td { vertical-align: top; }
.warn-mark { color: var(--warn); font-weight: 700; margin-left: 2px; }
.odd { margin-top: 4px; font-size: .8125rem; color: var(--warn); }
.odd summary { cursor: pointer; }
.odd ul { margin: 4px 0 0; padding-left: 18px; }

.selection-bar {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 12px -20px -20px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface-alt); border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
}
.selection-bar > span { margin-right: auto; }
.selection-bar.active { background: var(--primary-soft); border-top-color: #c7d5f7; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.inline-form { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.inline-form select { width: auto; min-height: 36px; padding: 4px 8px; font-size: .875rem; max-width: 14rem; }
.inline-details summary { list-style: none; display: inline-flex; }
.inline-details summary::-webkit-details-marker { display: none; }
.inline-details[open] summary { margin-bottom: 8px; }

.two-col { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.two-col .card { margin: 0; }

/* ── auth ──────────────────────────────────────────── */

body.auth { display: grid; place-items: center; min-height: 100vh; padding: 24px var(--gutter); }
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px 24px;
}
.auth-brand { color: var(--muted); font-weight: 600; font-size: .9375rem; margin-bottom: 4px; }
.auth-card h1 { margin-bottom: 20px; font-size: 1.375rem; }
.auth-card > p { margin-bottom: 16px; }
.auth-foot { margin-top: 20px; text-align: center; font-size: .9375rem; }

/* ── questionnaire list ────────────────────────────── */

.q-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.q-card h2 { margin-bottom: 4px; }
.q-card .meta { margin-top: 8px; font-size: .9375rem; color: var(--muted); }
.q-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 599px) { .q-card-actions, .q-card-actions .btn { width: 100%; } }

/* ── survey form ───────────────────────────────────── */

.survey { max-width: 820px; }
.survey > .muted { margin-bottom: 12px; }
.q-section > h2 { padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.q-section > .help { margin-top: 8px; }

.q { border: 0; margin: 0; padding: 20px 0 0; min-width: 0; }
.q + .q { border-top: 1px solid #eceef1; margin-top: 20px; }
.q-sub { margin-left: 16px; padding-left: 16px; border-left: 3px solid var(--primary-soft); }
.q + .q-sub { border-top: 0; margin-top: 8px; }
.q > legend, .q-title { display: block; padding: 0; margin-bottom: 10px; font-weight: 600; line-height: 1.5; }
.q > legend { float: left; width: 100%; }   /* lets the legend sit inside the fieldset padding */
.q > legend + * { clear: both; }
.q > .help { margin: -6px 0 10px; }
.q > .error { margin-top: 8px; }
.qno {
  display: inline-block; min-width: 2.5em; margin-right: 8px; padding: 0 6px;
  border-radius: 4px; background: var(--primary-soft); color: var(--primary);
  font-size: .8125rem; font-weight: 700; text-align: center; vertical-align: 1px;
}
.req { margin-left: 8px; color: var(--danger); font-size: .75rem; font-weight: 700; vertical-align: 1px; }

/* --min: the width the longest label needs (set per question), so short answers share a row. */
.choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--min, 9.5rem)), 1fr)); }
.choices-row { grid-template-columns: repeat(2, 1fr); }
.choices-fit { grid-template-columns: repeat(var(--n), 1fr); }
@media (min-width: 640px) { .choices-row { grid-template-columns: repeat(var(--n), 1fr); } }

.choice { position: relative; display: flex; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; pointer-events: none; }
.choice span {
  flex: 1;
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: 8px 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); line-height: 1.35; font-size: .9375rem;
}
.choice:hover span { background: var(--surface-alt); }
.choice input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.choice input:focus-visible + span { outline: 3px solid #93b4f5; outline-offset: 2px; }
.has-error .choice span { border-color: var(--danger); }

.matrix-row { padding: 10px 0; }
.matrix-row + .matrix-row { border-top: 1px dashed var(--border); }
.matrix-label { font-size: .9375rem; margin-bottom: 8px; }

.other { margin-top: 8px; }
.affix { display: flex; align-items: center; gap: 8px; }
.affix span { color: var(--muted); white-space: nowrap; font-size: .9375rem; }
.affix input { max-width: 12rem; }

.draft-note {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; margin-bottom: 16px;
  background: var(--warn-soft); border: 1px solid #f5d88a; border-radius: var(--radius);
}
.submit-bar {
  position: sticky; bottom: 0; z-index: 10;
  margin: 0 calc(-1 * var(--gutter)); padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.submit-bar .btn { width: 100%; }
.timer { margin: 0 0 8px; font-size: .875rem; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.submit-bar:has(.btn + .btn) .timer { grid-column: 1 / -1; }
.submit-bar:has(.btn + .btn) { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }

.saved { text-align: center; padding: 40px 20px; }

/* 施設の記録: photos */
.note-facility { margin: 0 0 12px; }
.note-rule { margin: 0 0 12px; padding: 8px 10px; font-size: .9375rem; background: var(--warn-soft); border: 1px solid #f5d88a; border-radius: var(--radius); }
.photo-pick label.btn { margin: 4px 0 8px; }
.photo-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); margin: 8px 0; }
.photo { position: relative; display: block; aspect-ratio: 4 / 3; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-alt); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-kind { position: absolute; left: 6px; bottom: 6px; padding: 1px 8px; border-radius: 999px; background: rgba(17, 24, 39, .75); color: #fff; font-size: .75rem; }
.photo-remove { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(17, 24, 39, .75); color: #fff; font-size: 1rem; cursor: pointer; }
.note .answers { margin-bottom: 8px; }

/* 再訪リスト */
.revisit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.revisit p { margin: 0 0 6px; }
.revisit-title { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.revisit-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0 0 !important; }
.saved-mark {
  width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ok-soft); color: var(--ok); font-size: 1.75rem; font-weight: 700;
}
.saved-mark-queued { background: var(--warn-soft); color: var(--warn); }
.saved-text { font-size: 1.125rem; margin-bottom: 24px; }
.saved-text + .muted { margin: -12px 0 24px; }
.saved-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
@media (max-width: 599px) { .saved-actions .btn { width: 100%; } }

/* ── results ───────────────────────────────────────── */

.filters { display: flex; align-items: flex-end; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 16px; }
.field-inline { display: grid; gap: 4px; font-size: .875rem; color: var(--muted); }
.field-inline input, .field-inline select { width: auto; min-width: 10rem; color: var(--text); }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tabs a {
  padding: 10px 16px; margin-bottom: -1px;
  color: var(--muted); text-decoration: none; font-weight: 600;
  border-bottom: 3px solid transparent;
}
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

.section-title { margin: 32px 0 12px; font-size: 1.0625rem; }
.result-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.result > .muted { margin: 4px 0 0; }
.result > .bars, .result > .table-wrap, .result > .numbers, .result > .texts { margin-top: 16px; }

.bars { display: grid; gap: 8px; }
.bar-row {
  display: grid; grid-template-columns: minmax(8rem, 16rem) 1fr 5.5rem;
  align-items: center; gap: 12px; font-size: .9375rem;
}
.bar-label { line-height: 1.35; }
.bar-label .badge, .result-head h3 .badge { margin-left: 6px; vertical-align: 1px; font-weight: 400; }
.bar-track { height: 20px; }
.bar-fill { display: block; height: 100%; min-width: 2px; background: var(--primary); border-radius: 0 4px 4px 0; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.bar-value small, .heat small { margin-left: 6px; font-weight: 400; color: var(--muted); }
@media (max-width: 599px) {
  .bar-row { grid-template-columns: 1fr 4.5rem; row-gap: 2px; }
  .bar-label { grid-column: 1 / -1; }
}

.matrix th[scope=row] { font-weight: 500; min-width: 10rem; }
.matrix thead th:not(:first-child), .matrix td { text-align: center; }
.heat {
  background: color-mix(in srgb, var(--primary) var(--p), var(--surface));
  font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap;
  border-left: 2px solid var(--surface);
}
.heat small { display: block; margin: 0; }
.heat-strong, .heat-strong small { color: #fff; }

.numbers { display: flex; gap: 32px; flex-wrap: wrap; margin: 0; }
.numbers dt { color: var(--muted); font-size: .875rem; }
.numbers dd { margin: 0; font-size: 1.5rem; font-weight: 700; }

.texts { list-style: none; margin: 0; padding: 0; max-height: 28rem; overflow-y: auto; }
.texts li { padding: 12px 0; border-top: 1px solid #eceef1; }
.texts li:first-child { border-top: 0; padding-top: 0; }
.texts li > p:first-child { white-space: pre-wrap; }

.others { margin-top: 12px; font-size: .9375rem; }
.others summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.others ul { margin: 8px 0 0; padding-left: 20px; }

.answers { margin: 0; }
.answers > div { display: grid; grid-template-columns: minmax(10rem, 18rem) 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid #eceef1; }
.answers > div:first-child { border-top: 0; }
.answers dt { color: var(--muted); font-size: .9375rem; }
.answers dd { margin: 0; }
@media (max-width: 599px) { .answers > div { grid-template-columns: 1fr; gap: 2px; } }
.plain { margin: 0; padding: 0; list-style: none; }
.edits { margin: 0; padding: 0; list-style: none; }
.edits > li { padding: 10px 0; border-top: 1px solid #eceef1; }
.edits > li:first-child { border-top: 0; padding-top: 0; }
.edits p { margin: 0 0 4px; }

/* ── 施設検索 (open data) ──────────────────────────── */

.select-auto { width: auto; max-width: 12rem; }
.town-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.town-list a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 48px; padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  color: var(--text); text-decoration: none; font-weight: 600;
}
.town-list a:hover, .town-list a:active { border-color: var(--primary); background: var(--primary-soft); }
.listing-group { margin-bottom: 16px; }
.listing-group h2 { margin-bottom: 4px; }
.listing-list { list-style: none; margin: 0; padding: 0; }
.listing { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.listing:last-child { border-bottom: 0; padding-bottom: 0; }
.listing-main { min-width: 0; display: grid; gap: 2px; }
.listing-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }
.listing-main .badge { margin-left: 4px; vertical-align: 2px; }
.listing-main a { overflow-wrap: anywhere; }
.credit { margin-top: 20px; }
@media (max-width: 599px) { .listing { flex-direction: column; align-items: flex-start; } .select-auto { flex: 1; max-width: none; } }

/* ── 地図 ──────────────────────────────────────────── */

.map-kinds { display: grid; gap: 2px; }
.map-kind { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: .9375rem; }
.map-kind input { width: 18px; height: 18px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); vertical-align: -1px; }
.kind-0 { background: #7c3aed; }
.kind-1 { background: #1d4ed8; }
.kind-2 { background: #c2410c; }
.kind-3 { background: #4b5563; }
.map { height: calc(100vh - var(--topbar) - 190px); min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius); background: #eef0f3; }
.map-wrap { position: relative; isolation: isolate; }   /* the map's own layers (z-index 400–1000) stay under the menu */

/* 地図 over the whole space beside the menu; its controls sit on it, top right. */
.main-full { max-width: none; padding: 0; }
.main-full > .flash { margin: 12px; }
.map-full .map { height: calc(100vh - var(--topbar)); height: calc(100dvh - var(--topbar)); min-height: 320px; border: 0; border-radius: 0; }
.map-controls { position: absolute; top: 10px; right: 10px; z-index: 1000; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.map-controls [hidden] { display: none; }
.map-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(17, 24, 39, .25); font: inherit; font-weight: 600; font-size: .9375rem; cursor: pointer;
}
.map-btn:hover { background: var(--surface-alt); }
.map-btn[aria-expanded="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.map-btn:disabled { opacity: .6; }
.map-menu {
  position: absolute; top: 10px; right: 126px; z-index: 1001; width: min(300px, calc(100% - 20px));
  max-height: calc(100% - 20px); overflow-y: auto; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 2px 8px rgba(17, 24, 39, .25);
}
.map-menu[hidden] { display: none; }
.map-menu h2 { font-size: 1rem; margin-bottom: 6px; }
.map-menu p { margin: 8px 0 0; }
.map-menu p .visit { margin: 0 2px 0 8px; }
@media (max-width: 599px) {
  .map-controls { flex-direction: row; }
  .map-menu { right: 10px; top: 62px; max-height: calc(100% - 72px); }
}
.edit-bar { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 1000; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 2px 8px rgba(17, 24, 39, .25); }
.edit-bar[hidden] { display: none; }
/* A selected pin's details, over the bottom of the map: a card in the corner on wide screens, the
   width of the map on phones. Folded, only its title line shows. */
.map-panel {
  position: absolute; left: 8px; bottom: 26px; z-index: 1000; width: min(360px, calc(100% - 16px));   /* the tiles' credit stays visible */
  display: flex; flex-direction: column; max-height: 45%;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(17, 24, 39, .25);
}
.map-panel[hidden] { display: none; }
.map-panel-head { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border-bottom: 1px solid var(--border); }
.map-panel.is-folded { max-height: 46px; overflow: hidden; }   /* the body stays, clipped, so the height can ease */
.map-panel.is-folded .map-panel-head { border-bottom: 0; }
.map-panel-title { flex: 1; min-width: 0; margin: 0; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-panel-body { overflow-y: auto; padding: 10px 12px 12px; }
.map-panel .house-list { max-height: none; }
@media (max-width: 599px) { .map-panel { left: 8px; right: 8px; width: auto; } }
.edit-title { margin: 0 0 2px; font-weight: 700; }
.edit-bar .small { margin: 0 0 8px; }
.edit-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.edit-reason { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: .875rem; }
.edit-reason select { flex: 1; min-width: 0; }
.pin { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; }
.pin-lot { background: var(--border-strong); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); }
.pin-town { background: #fff; border: 3px solid var(--border-strong); }
.visit { display: inline-block; width: 11px; height: 11px; border: 2px solid #fff; box-shadow: 0 0 0 1px #111827; transform: rotate(45deg); vertical-align: 0; }
.visit-ok { background: #15803d; }
.visit-away { background: #d1d5db; }
.visit-refused { background: #4b5563; }
.visit-icon span { display: block; width: 12px; height: 12px; margin: 2px; border: 2px solid #fff; box-shadow: 0 0 0 1px #111827; transform: rotate(45deg); }
.near-count { color: var(--ok); font-weight: 600; }
.place-map-wrap { position: relative; isolation: isolate; margin: 8px 0; }
.place-map { height: 300px; border: 1px solid var(--border); border-radius: var(--radius); background: #eef0f3; }
/* What the map shows, folded behind 表示 in its corner like on 地図. */
.place-layers { position: absolute; top: 8px; right: 8px; z-index: 1000; }
.place-layers summary { list-style: none; min-height: 40px; padding: 0 12px; }
.place-layers summary::-webkit-details-marker { display: none; }
.place-layers[open] summary { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.place-layers .map-menu { top: 48px; right: 0; width: min(300px, calc(100vw - 64px)); max-height: 240px; }
.place-layers .layer-toggles { margin-top: 0; }
.place-status { font-size: .9375rem; margin: 0 0 8px; }
.place-warn { color: var(--warn); }
.place-near { margin: 0 0 8px; padding: 8px 10px; font-size: .9375rem; background: var(--warn-soft); border: 1px solid #f5d88a; border-radius: var(--radius); }
.place-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.place-pin span { display: block; width: 22px; height: 22px; border-radius: 50%; background: #2563eb; border: 3px solid #111827; box-shadow: 0 0 0 2px #fff; }

.near-list { list-style: none; margin: 0; padding: 0; }
.near-list li + li { border-top: 1px solid var(--border); }
.near-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 8px 4px; background: none; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.near-item:hover { background: var(--surface-alt); }
.near-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.near-title { font-weight: 600; }
.near-dist { color: var(--muted); }
.cluster { display: grid; place-items: center; border-radius: 50%; background: rgba(29, 78, 216, .9); color: #fff; font-weight: 700; font-size: .875rem; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(17, 24, 39, .35); }
.map-popup p { margin: 0 0 4px; font-size: .875rem; line-height: 1.5; }
.map-popup .map-popup-title { font-weight: 700; font-size: 1rem; }
.map-popup-links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px !important; }
.leaflet-container { font: inherit; isolation: isolate; }   /* its layers (z-index 400+) stay under the menu and sticky bars */
.pager { display: flex; gap: 8px; justify-content: space-between; margin: 12px 0; }
.pager:empty { display: none; }

/* ── 訪問位置と対象の施設, answers per facility ─────── */

.layer-toggles { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 12px; }
.layer {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 10px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface);
  font-size: .875rem; cursor: pointer; user-select: none;
}
.layer input { position: absolute; opacity: 0; pointer-events: none; }
.layer:has(input:not(:checked)) { color: var(--muted); border-color: var(--border); background: var(--surface-alt); text-decoration: line-through; }
.layer:has(input:not(:checked)) .dot, .layer:has(input:not(:checked)) .visit { opacity: .35; }
.layer:has(input:focus-visible) { outline: 3px solid #93b4f5; outline-offset: 2px; }

.pick-targets { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.pick-targets h3 { margin: 0 0 4px; font-size: 1rem; }
.pick-targets.has-error .target-list:first-of-type { outline: 2px solid var(--danger); outline-offset: 4px; border-radius: 4px; }
.target-list { list-style: none; margin: 8px 0 0; padding: 0; }
.target-list li + li { border-top: 1px solid var(--border); }
.target-item { display: flex; align-items: stretch; }
.target-item.is-focus { background: var(--primary-soft); }
.target-item.is-picked .target-title { font-weight: 700; }
.target-check { display: grid; place-items: center; width: 52px; flex: none; cursor: pointer; }
.target-check input { width: 24px; height: 24px; }
.target-name {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 52px; padding: 6px 4px;
  background: none; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.target-name:hover { background: var(--surface-alt); }
.target-text { flex: 1; min-width: 0; display: grid; }
.target-title { overflow-wrap: anywhere; }
.target-search { margin-top: 12px; }
.target-no {
  display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--c, #111827); color: #fff; font-size: .8125rem; font-weight: 700;
}
.target-icon span {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 700; font-size: .875rem;
  border: 2px solid #fff; box-shadow: 0 0 0 2px #111827;
}
.focus-ring { animation: focus-ring 1.2s ease-out 2; }
@keyframes focus-ring { from { stroke-width: 8; } to { stroke-width: 3; } }
.focus-label { font-weight: 700; }

/* Houses: several at one point (an apartment building) are one pin with their count. */
.visit-icon .visit-group {
  display: grid; place-items: center; width: 20px; height: 20px; margin: -2px; transform: none; border-radius: 4px;
  background: #15803d; color: #fff; font-size: .75rem; font-weight: 700;
}
.visit-icon .visit-group-away { background: #d1d5db; color: #111827; }
/* The selection's lines and circle are drawn above the pins but must not take their taps. */
.leaflet-links-pane, .leaflet-links-pane svg { pointer-events: none; }
.link-label { font-weight: 600; font-size: .8125rem; padding: 2px 6px; }
.house-list { list-style: none; margin: 0; padding: 0; max-height: 16rem; overflow-y: auto; }
.house-list li + li { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.house-memo { margin-top: 12px; }
.revisit-note { margin: 8px 0 12px; padding: 10px 14px; background: var(--primary-soft); border: 1px solid #c7d5f7; border-radius: var(--radius); }
.revisit-note p { margin: 0 0 4px; }
.visit-list { margin: 4px 0 8px; padding-left: 1.25rem; font-size: .9375rem; }

/* The tabs stay in view (under the top bar) while the questions scroll under them; the note under
   them scrolls away, so the pinned bar is one line of tabs. */
.target-block { scroll-margin-top: var(--topbar); }
.target-bar {
  position: sticky; top: var(--topbar); z-index: 15;
  margin: 0 calc(-1 * var(--gutter)) 16px; padding: 8px var(--gutter);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.target-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.target-tabs:empty { display: none; }
.target-tab {
  display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; flex: none;
  max-width: 16rem; min-height: 52px; padding: 6px 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  font: inherit; color: var(--text); text-decoration: none; cursor: pointer;
}
.target-tab .target-no { grid-row: span 2; }
.target-tab-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.target-tab-meta { font-size: .8125rem; color: var(--muted); white-space: nowrap; }
.target-tab.active { border: 2px solid var(--primary); background: var(--primary-soft); padding: 5px 11px; }
.target-tab.active .target-tab-name { color: var(--primary); }
.target-tabs-static { margin: 12px 0 16px; }
.target-tabs-static .target-no { background: #111827; }
.target-note { margin: -8px 0 16px; font-size: .9375rem; line-height: 1.5; }
.target-note-own { padding: 6px 10px; background: var(--warn-soft); border: 1px solid #f5d88a; border-radius: var(--radius); }
.own-list { color: var(--warn); font-weight: 600; }

/* A facility's own answer, apart from the first's. */
.q-own { margin-left: -12px; padding-left: 9px; border-left: 3px solid #d97706; }
.q-own + .q { border-top-color: #eceef1; }
.own-mark { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 10px; font-size: .8125rem; color: var(--warn); font-weight: 600; clear: both; }
.own-mark span:first-child { padding: 1px 8px; border-radius: 999px; background: var(--warn-soft); border: 1px solid #f5d88a; }
.answers .own-mark { margin: 4px 0 0; font-weight: 400; }
.answer-own dd { font-weight: 600; }


.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.prose h2 { margin-bottom: 8px; }
.prose p, .prose ul { margin: 8px 0 0; line-height: 1.7; }
.prose ul { padding-left: 1.25rem; }

/* ── Motion: short and quiet, so things appear and change size instead of jumping. None when the
   device asks for reduced motion. ─────────────────────────────────────────────────────────── */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
@keyframes appear { from { opacity: 0; transform: translateY(-4px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } 60% { transform: scale(1.08); } }

.btn, .choice span, .map-btn, .target-tab, .target-name, .target-item, .near-item, .sidebar a, .stat-link, .layer,
.pick, .town-list a, .tabs a, .target-note {
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.map-panel { transition: max-height .22s ease; }
.map-panel:not([hidden]) { animation: rise .22s ease-out; }
.map-menu:not([hidden]) { animation: drop .16s ease-out; transform-origin: top right; }
.leaflet-links-pane path, .link-label { animation: fade .25s ease-out; }
.flash, .draft-note:not([hidden]), .appear { animation: appear .2s ease-out; }
.saved-mark { animation: pop .4s ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.signature { display: block; width: 100%; max-width: 360px; height: auto; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; }
