* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.skip-link { position: fixed; left: 12px; top: -48px; z-index: 200; background: var(--navy); color: #fff; padding: 8px 12px; }
.skip-link:focus { top: 12px; }

.app-shell { width: min(100%, 1240px); max-width: 1180px; margin: 0 auto; padding: 0 32px 56px; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(20px, 3.4vw, 26px); line-height: 1.3; font-weight: 700; }
h2 { margin-bottom: 0; font-size: 18px; line-height: 1.35; font-weight: 700; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .18em;
}

/* ページ見出し */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 0 20px;
  border-bottom: 1px solid var(--line);
}

.brand-block { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--navy);
}

.brand-mark svg { width: 22px; }

.header-actions { display: flex; align-items: center; gap: 10px; }
.updated-label { margin: 0; color: var(--muted); font-size: 12px; text-align: right; }

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--navy);
  background: #fff;
  transition: border-color .15s ease, color .15s ease;
}

.icon-button:hover { border-color: var(--accent); color: var(--accent-strong); }
.icon-button svg { width: 18px; }

/* 対象地震。現在地ボタンと同じブルーで、このサイトの主役だと分かるようにします。 */
.event-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 18px 0;
  padding: 22px 24px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--accent);
  box-shadow: 0 10px 24px rgba(0, 102, 204, .22);
}

.event-band .eyebrow { color: rgba(255, 255, 255, .82); }
.event-band h2 { color: #fff; font-size: clamp(18px, 2.6vw, 22px); }
.event-meta { margin: 6px 0 0; color: rgba(255, 255, 255, .92); font-size: 14px; }

.event-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.event-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.event-updated {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: rgba(255, 255, 255, .92);
  font-size: 12px;
  white-space: nowrap;
}

.icon-button-on-blue {
  border-color: rgba(255, 255, 255, .5);
  color: #fff;
  background: rgba(255, 255, 255, .14);
}

.icon-button-on-blue:hover { border-color: #fff; color: #fff; background: rgba(255, 255, 255, .26); }

.status-dot { display: block; width: 8px; height: 8px; border-radius: 50%; background: #8ff0bb; box-shadow: 0 0 0 3px rgba(143, 240, 187, .28); }

/* 集計 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  overflow: hidden;
}

.stat-item { min-height: 96px; padding: 16px 20px; background: var(--panel); }
.stat-item span { display: block; color: var(--muted); font-size: 12px; }
.stat-item strong { margin-right: 4px; color: var(--navy); font-family: var(--mono); font-size: 30px; line-height: 1.3; }
.stat-item small { color: var(--muted); font-size: 12px; }

/* 図表 */
.workspace { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, .85fr); gap: 18px; margin-top: 18px; }

.chart-panel, .municipality-panel, .notices-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.chart-panel { padding: 20px 20px 14px; }
.municipality-panel { padding: 20px; }

.panel-heading, .section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend b { flex: 0 0 9px; width: 9px; height: 9px; border-radius: 50%; }
.legend-confirmed { background: var(--confirmed); }
.legend-possible { background: var(--possible); }
.legend-note { color: var(--muted); font-size: 11px; white-space: normal; }

#timeline-chart { display: block; width: 100%; height: 232px; margin-top: 16px; }
.timeline-labels { display: flex; justify-content: space-between; min-height: 18px; color: var(--muted); font-family: var(--mono); font-size: 10px; }

.municipality-list { display: grid; gap: 9px; margin-top: 17px; max-height: 280px; overflow: auto; padding-right: 4px; }
.municipality-row { display: grid; grid-template-columns: 82px 1fr 30px; align-items: center; gap: 8px; font-size: 13px; }

.municipality-row button {
  overflow: hidden;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.municipality-row button:hover { color: var(--accent-strong); text-decoration: underline; }
.municipality-bar { height: 7px; border-radius: 4px; background: #e6ecf4; overflow: hidden; }
.municipality-bar > span { display: block; height: 100%; min-width: 5px; background: var(--accent); }
.municipality-count { color: var(--muted); font-family: var(--mono); font-size: 12px; text-align: right; }

/* 一覧 */
.notices-section { margin-top: 18px; padding: 22px; }
.result-count { margin: 0; color: var(--muted); font-size: 13px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-light);
}

.search-field {
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  gap: 8px;
  min-width: 200px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.search-field svg { width: 16px; color: var(--muted); }
.search-field input { width: 100%; height: 36px; border: 0; outline: 0; background: transparent; }

.select-field { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }

.select-field select {
  width: 148px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  color: var(--ink);
  background: #fff;
}

.segmented { display: flex; height: 36px; border: 1px solid var(--line); border-radius: 6px; background: #fff; overflow: hidden; }

.segmented button {
  min-width: 62px;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.segmented button:last-child { border-right: 0; }
.segmented button.active { color: #fff; background: var(--accent); }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }

th {
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

td { padding: 12px 10px; border-bottom: 1px solid #eef2f7; vertical-align: top; }
tr:last-child td { border-bottom: 0; }

.time-cell { color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; }

.municipality-tag {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #c8daf2;
  border-radius: 4px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 12px;
  white-space: nowrap;
}

.category-label { color: var(--muted); font-size: 12px; white-space: nowrap; }

.notice-link { display: block; color: var(--ink); font-weight: 700; text-decoration: none; }
.notice-link:hover { color: var(--accent-strong); text-decoration: underline; }

/* 自治体などの別サイトへ移動するので、見出しの後ろにアイコンを添えます。 */
.notice-link::after {
  content: "";
  display: inline-block;
  width: .82em;
  height: .82em;
  margin-left: 6px;
  vertical-align: -.04em;
  background-color: currentColor;
  -webkit-mask: var(--icon-external) no-repeat center / contain;
  mask: var(--icon-external) no-repeat center / contain;
  opacity: .55;
}

.notice-sub {
  display: inline-block;
  margin-top: 4px;
  border: 0;
  padding: 0;
  color: var(--accent);
  background: transparent;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.status-label { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; white-space: nowrap; }
.status-confirmed { color: var(--confirmed); background: var(--confirmed-soft); }
.status-possible { color: #8a5a00; background: var(--possible-soft); }

.empty-state { padding: 28px; color: var(--muted); text-align: center; }

/* 詳細 */
.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 300;
  width: min(440px, 94vw);
  height: 100dvh;
  transform: translateX(100%);
  padding: 20px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -12px 0 28px rgba(3, 50, 133, .16);
  transition: transform .18s ease;
}

.detail-drawer.open { transform: translateX(0); }
.drawer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 299; background: rgba(3, 50, 133, .32); }
.drawer-title { margin-bottom: 16px; font-size: 20px; line-height: 1.5; }

.detail-list { display: grid; gap: 12px; margin: 0; }
.detail-list div { display: grid; gap: 3px; padding-bottom: 10px; border-bottom: 1px solid #eef2f7; }
.detail-list dt { color: var(--muted); font-size: 11px; }
.detail-list dd { margin: 0; word-break: break-word; }

.external-link { display: inline-flex; align-items: center; gap: 6px; margin-top: 20px; color: var(--accent-strong); font-weight: 700; }
.external-link svg { width: 15px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .municipality-list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 220px; }
}

@media (max-width: 760px) {
  .app-shell { padding: 0 20px 40px; }
  .app-header { padding: 20px 0 16px; }
  .updated-label { display: none; }
  .event-band { align-items: flex-start; flex-direction: column; padding: 18px; }
  .event-side { align-items: flex-start; width: 100%; }
  .notices-section { padding: 16px; }
}

@media (max-width: 520px) {
  .brand-mark { flex-basis: 36px; width: 36px; height: 36px; }
  .filter-bar { align-items: stretch; }
  .select-field, .select-field select, .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .municipality-list { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-item { min-height: 84px; padding: 14px 16px; }
  .stat-item strong { font-size: 26px; }
}

/* 帯の中の説明文。何をしているサイトかを最初の一目で伝えます。 */
.event-lead {
  max-width: 62ch;
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .28);
  color: rgba(255, 255, 255, .94);
  font-size: 13px;
  line-height: 1.85;
}

@media (max-width: 760px) {
  .event-lead { font-size: 12.5px; line-height: 1.8; }
}
