* { box-sizing: border-box; margin: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: #f8f9fa; color: #1a1a1a; }
.container { max-width: 960px; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.25rem; font-weight: 600; }
.sub { font-size: 0.75rem; color: #666; margin-top: 2px; }
.header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem; }
.controls { display: flex; gap: 0.5rem; align-items: center; }
select, button { font-size: 0.8rem; padding: 6px 12px; border: 1px solid #ccc; border-radius: 6px; background: #fff; cursor: pointer; }

@media (max-width: 480px) {
  .header { flex-direction: column; }
  .controls { width: 100%; }
  .controls select { width: 100%; }
  h1 { font-size: 1.1rem; }
  .criteria-box { font-size: 0.68rem; }
  .criteria-box p { line-height: 1.5; }
  .legend { font-size: 0.68rem; }
  .disclaimer { font-size: 0.6rem; }
  .chips { gap: 4px; }
  .chip { font-size: 0.7rem; padding: 3px 8px; }
}
button:hover { background: #f0f0f0; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Tile Map */
.tile-map-container { margin-bottom: 1rem; }
.tile-map {
  --tile-size: min(60px, calc((100vw - 2rem - 36px) / 12));
  display: grid;
  grid-template-columns: repeat(12, var(--tile-size));
  grid-template-rows: repeat(14, calc(var(--tile-size) * 0.65));
  gap: 3px;
  justify-content: center;
}
.tile {
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(0.45rem, 1.5vw, 0.7rem); font-weight: 500;
  border-radius: 4px; cursor: pointer;
  transition: filter 0.15s;
  color: #1a1a1a;
  text-decoration: none;
  line-height: 1.1;
  text-align: center;
}
.tile:hover { filter: brightness(0.85); }
.tile-warning { background: #dc3545; color: #fff; }
.tile-risk { background: #f59e0b; }
.tile-low { background: #22c55e; color: #fff; }
.tile-nodata { background: #e5e7eb; }

@media (max-width: 480px) {
  .tile-map { gap: 2px; }
  .tile { border-radius: 3px; }
}

/* Legend */
.map-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 0.75rem; color: #666; flex-wrap: wrap; align-items: center; }
.map-legend-item { display: flex; align-items: center; gap: 4px; }
.map-legend-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* Chips */
.chips { display: flex; gap: 8px; margin-bottom: 1rem; flex-wrap: wrap; }
.chip { padding: 4px 12px; font-size: 0.8rem; border-radius: 6px; border: 1px solid; }
.chip-off { background: #f5f5f5; color: #999; border-color: #e0e0e0; }
.chip-on { background: #fff3cd; color: #856404; border-color: #ffc107; }

/* Banner */
.banner { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 0.8rem; border: 1px solid; }
.banner-warn { background: #fff3cd; color: #856404; border-color: #ffc107; }
.banner-ok { background: #d4edda; color: #155724; border-color: #28a745; }
.banner-err { background: #f8d7da; color: #721c24; border-color: #dc3545; }
.banner p { margin: 2px 0; }
.banner p:first-child { font-weight: 500; }

.loading { color: #666; font-size: 0.85rem; padding: 2rem 0; }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; background: #fff; }
.table-wrap { border: 1px solid #e0e0e0; border-radius: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
th { padding: 8px 12px; background: #f5f5f5; border-bottom: 1px solid #ddd; font-weight: 500; font-size: 0.75rem; color: #555; white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; white-space: nowrap; }

@media (max-width: 480px) {
  th, td { padding: 6px 8px; font-size: 0.7rem; }
  .badge { font-size: 0.6rem; padding: 2px 6px; }
}
.r { text-align: right; font-variant-numeric: tabular-nums; }
.c { text-align: center; }
.danger { color: #dc3545; font-weight: 500; }
.muted { color: #aaa; }

/* Badge */
.badge { display: inline-block; padding: 2px 10px; font-size: 0.7rem; border-radius: 6px; font-weight: 500; white-space: nowrap; }
.badge-low { background: #d4edda; color: #155724; }
.badge-caution { background: #fff3cd; color: #856404; }
.badge-warning { background: #f8d7da; color: #721c24; }
.badge-nodata { background: #f5f5f5; color: #999; }

/* Legend detail */
.legend { margin-top: 14px; padding: 10px 14px; background: #f5f5f5; border-radius: 8px; font-size: 0.75rem; color: #666; line-height: 1.8; }
.legend b { font-weight: 500; }
details { margin-top: 12px; }
summary { font-size: 0.75rem; color: #999; cursor: pointer; }
pre { margin-top: 4px; padding: 8px; font-size: 0.68rem; background: #f5f5f5; border-radius: 6px; color: #666; max-height: 180px; overflow: auto; }
.source { margin-top: 8px; font-size: 0.7rem; color: #999; }
.disclaimer { margin-top: 6px; font-size: 0.65rem; color: #aaa; line-height: 1.6; }
.disclaimer p { margin: 2px 0; }

/* Criteria box */
.criteria-box { padding: 10px 14px; background: #f5f5f5; border-radius: 8px; font-size: 0.75rem; color: #666; line-height: 1.8; margin-bottom: 1rem; }
.criteria-box p { margin: 2px 0; }
.criteria-box b { font-weight: 500; }

/* Articles */
.articles-section { margin-top: 1.5rem; margin-bottom: 1rem; }
.articles-section h2 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.6rem; color: #333; }
.articles-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.article-card {
  display: block; padding: 12px 14px; background: #fff; border: 1px solid #e5e7eb;
  border-radius: 8px; text-decoration: none; color: inherit; transition: box-shadow 0.15s;
}
.article-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.article-card-title { font-size: 0.8rem; font-weight: 600; color: #1a1a1a; margin-bottom: 4px; }
.article-card-desc { font-size: 0.7rem; color: #666; line-height: 1.5; }

@media (max-width: 480px) {
  .articles-grid { grid-template-columns: 1fr; }
  .article-card-title { font-size: 0.75rem; }
  .article-card-desc { font-size: 0.65rem; }
}

/* Back button */
.back-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; color: #2563eb; text-decoration: none; margin-bottom: 12px; cursor: pointer; background: none; border: none; padding: 0; }
.back-btn:hover { text-decoration: underline; }
