.tool-main {
  max-width: 1100px;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.title-row h1 {
  margin-bottom: 0;
}

.btn-explain {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
  background: none;
  border: none;
  border-bottom: 1px solid var(--text-sub);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-explain:hover {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ===== 統計グリッド ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  text-align: center;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 0.2rem;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  word-break: break-all;
}

/* ===== セクションタイトル ===== */
.section-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.35rem;
  margin-bottom: 0.75rem;
}

.sorted-data {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.8;
  word-break: break-all;
}

/* ===== グラフエリア ===== */
.chart-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.log-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  user-select: none;
}

.log-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--blue);
  cursor: pointer;
}

.chart-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.chart-tab {
  padding: 0.3rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-sub);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.chart-tab + .chart-tab {
  border-left: 1px solid var(--border);
}

.chart-tab.active {
  background: var(--text);
  color: var(--surface);
}

.chart-wrap {
  position: relative;
  height: 240px;
}

/* ===== モーダル ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem 0.7rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-sub);
  cursor: pointer;
  padding: 0 0.2rem;
  transition: color 0.1s;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  overflow-y: auto;
  padding: 0.9rem 1.1rem 1.1rem;
}

.explain-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  padding: 0;
}

.explain-item {
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 0;
}

.explain-item:last-child {
  border-bottom: none;
}

.explain-item dt {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.explain-item dd {
  font-size: 0.83rem;
  color: var(--text-sub);
  line-height: 1.6;
  margin: 0;
}
